Area Of Square Example Java Program


In classical times, the second power was described in terms of the area of a square, as in the above formula. This led to the use of the term square to mean raising to the second power. Thus the area of the square is twice the length of the square.


The area of a square is written as,

s=side of the square

Area Of Square Example Program

import java.util.Scanner;
class AreaOfSquare{
	static Scanner in = new Scanner(;
	public static void main(String args[]){
		System.out.print("Enter the length: ");
		int length = in.nextInt();
		int area=length*length;
		System.out.println( "The area of the square is:"+area) ;

Sample Output

Output is:
Enter the length: 4
The area of the square is:16