In this example we will show how to calculate perimeter of rectangle using it’s length and width.
Source Code
package com.beginner.examples;
public class RectanglePerimeterExample {
public static void main(String[] args){
int a = 10;
int b = 5;
//return perimeter of a rectangle.
double area = 2 * (a + b);
System.out.println("Perimeter of a rectangle is " + area);
}
}
Output:
Perimeter of a rectangle is 30.0