programme that calculate rectangle area java using class and object code example
Example: Calculate area of rectangle using class in java
import java.io.*;
class RectangleShape
{
int length, breadth;
void setValue(int l, int b)
{
length = l;
breadth = b;
}
int findArea()
{
return (length * breadth);
}
}
public class RectangleAreaDemo
{
public static void main(String[] args)
{
RectangleJava obj = new RectangleJava();
obj.setValue(10, 5);
System.out.println("Area of rectangle: " + obj.findArea());
}
}