Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package rectangle;
- public class Rectangle {
- int length, width;
- void getData(int x, int y)
- {
- length=x;
- width=y;
- }
- int rectArea()
- {
- int area=length*width;
- return (area);
- }
- }
- class RectArea{
- public static void main(String[] args) {
- int area1, area2;
- Rectangle rect1 =new Rectangle();
- Rectangle rect2 =new Rectangle();
- rect1.length=14;
- rect1.width=13;
- area1=rect1.length*rect1.width;
- rect2.getData(13,14);
- area2=rect2.rectArea();
- System.out.println("Area1="+ area1);
- System.out.println("Area1="+ area2);
- }
- }
- area1=rect1.area
- system.out.println("Area1="+ area1);
Add Comment
Please, Sign In to add comment