Question: How can debug this program? Can you help me to check my code? public class Rectangle { private int lenght; private int width; public Rectangle(int

How can debug this program? Can you help me to check my code?

public class Rectangle { private int lenght; private int width;

public Rectangle(int length) { this.length = length; } public int getLength() { return length; } public Rectangle(int width) { this.width = width; } public int getWidth() { return width; } public Rectangle(int area) { this.area = area; } public int getArea() { return length*width; } public boolean equals (Rectangle r1, Rectangle r2) { if (r1.getArea() == r2.getArea()) return true; else return false; } }

public class CompareUsingequalsMethod { public static void main(String[] args) {

Rectangle r1 = new Rectangle(3, 5); Rectangle r2 = new Rectangle(4, 4);

if (r1.equals(r1,r2)) { System.out.println("Rectangle1 with area " + r1.getArea() + " is equal to Rectangle2 with " + "area " + r2.getArea()); } else { System.out.println("Rectangle1 with area " + r1.getArea() + " is not equal to Rectangle2 with " + "area " + r2.getArea()); }

}

}

} How can debug this program? Can you help me to check my

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!