Create a class Rectangle with attributes length and width. Use a constructor to initialize values and calculate the area
class Rectangle
{
int length, width;
Rectangle(int l,int w)
{
length=l;
width=w;
}
int area()
{
return length*width;
}
}
class Main
{
public static void main(String args[])
{
Rectangle r=new Rectangle(10,2);
System.out.println(“Area=” +r.area());
}
}