Untitled
unknown
plain_text
2 years ago
715 B
6
Indexable
class Rectangle {
public int len;
public int wid;
Rectangle(){}
Rectangle (int l,int w) {
len=l;
wid =w;
}
void input(int l,int w)
{
len=l;
wid =w;
}
int area()
{
return len* wid;
}
void display()
{
System.out.print("len is : "+ len+"wid is : "+wid);
}
}
public class Main
{
public static void main(String[] args) {
Rectangle r1 = new Rectangle(4, 6);
// r1.display();
r1.display();
System.out.print(" the area is: " + r1.area());
Rectangle r2 = new Rectangle(6, 10);
r2.display();
System.out.print(" the area is: " + r2.area());
}
}
Editor is loading...
Leave a Comment