Check out example codes for "Java program to find perimeter of square". It will help you in understanding the concepts better.

Code Example 1

import java.util.Scanner;
public class SquarePerimeter
{
   public static void main(String[] args)
   {
      int side, perimeter;
      Scanner sc = new Scanner(System.in);
      System.out.print("Please enter side length of square: ");
      side = sc.nextInt();
      perimeter = 4 * side;
      System.out.print("Perimeter of square is: " + perimeter);
      sc.close();
   }
}

Code Example 2

java program to calculate area of square
import java.util.Scanner;
public class FindAreaOfSquare
{
   public static void main(String[] args)
   {
      Scanner sc = new Scanner(System.in);
      System.out.println("Please enter side of square: ");
      double side = sc.nextDouble();
      // formula area of square = side * side
      double area = side * side;
      System.out.println("Area of square is: " + area);
      sc.close();
   }
}

Learn ReactJs, React Native from akashmittal.com