## 2 Ways To Find Area of Rectangle in Java Programming

Here, we have described Two Methods To Calculate Area of Rectangle in Java Programming Language. This is a Java Code To Find Area of Rectangle using Parameters with a self-explanatory program.

**Area of Rectangle = Length * Breadth**

#### Method 1: Java Program To Calculate Area of Rectangle without Parameters

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import java.io.*; class Rectangle { double length, breadth; double area() { return length * breadth; } } class Area { public static void main(String args[]) { double area; Rectangle rec1 = new Rectangle(); rec1.length = 20; rec1.breadth = 30; area = rec1.area(); System.out.println("\nArea of Rectangle: " + area + "\n"); } } |

**Also Read: Find Area of Triangle Java Program**

#### Method 2: Find Area of Rectangle in Java with Parameters

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import java.io.*; class Rectangle { double length, breadth; double area() { return length * breadth; } void value(double l, double b) { length = l; breadth = b; } } class Area { public static void main(String args[]) { double area; Rectangle rec1 = new Rectangle(); rec1.value(20, 30); area = rec1.area(); System.out.println("\nArea of Rectangle: " + area + "\n"); } } |

**Also Read: Java Program To Find Armstrong Number**

#### Output

In case you get any Compilation Errors with this Code To Calculate Area of Rectangle in Java or if you have any doubt about it, mention it in the Comment Section.