How to Calculate Rectangle Area in Java


This example demonstrates how to calculate area of Rectangle using it’s length and width.

Source Code

package com.beginner.examples;

public class RectangleAreaExample {

    public static void main(String[] args){
    	
    	int a = 10;
    	int b = 5;
    	//return area of a rectangle.
    	double area = a * b;
		
		System.out.println("Arae of a rectangle is " + area);
    }
}

Output:

Arae of a rectangle is 50.0
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments