Skip to content
Home » Java Programs » Perimeter of Rectangle in Java Program

Perimeter of Rectangle in Java Program

Perimeter of rectangle in java. In a Java program, measure the length and breadth. The region and perimeter will be printed in the java program’s output. The length and width of the input will be printed as a field and perimeter in the output. The term “length” refers to how long something is, or how much vertical space or time it occupies. A closed geometrical figure’s boundary is defined as a continuous line.

How to Calculate Value of Length and Perimeter of Rectangle

The perimeter of a rectangle is the sum of the lengths of all its sides. As a result, we can calculate the perimeter of a rectangle by adding all four sides. The specified rectangle’s perimeter is a + b + a + b.

Length and How to Calculate Length

A rectangle has two sides: length (L) and width (W) (W). The longest side of a rectangle is the length, while the shortest side is the width. The breadth of a rectangle is another term for its width (b).

Perimeter and How to Calculate

The perimeter of a shape is the distance around its edge. Learn how to calculate the perimeter of various forms by adding up the side lengths.

import java.util.Scanner;
public class Main
public static void main(String args[])
int length, breadth, peri, area;
Scanner scan = new Scanner(;
System.out.print("Enter length and breadth");
length = scan.nextInt();
breadth = scan.nextInt();
area = length*breadth;
peri = (2*length) + (2*breadth);
System.out.print("Area = " +area);
System.out.print("\nPerimeter = " +peri);


Enter length and breadth
34 56
Area = 1904 Perimeter = 180