In Java, the equals() method is an instance method of an Object class that accepts another object,
Fantastic news! We've Found the answer you've been seeking!
Question:
In Java, the equals() method is an instance method of an Object class that accepts another object, checking to see if it is the same as the instance itself. Assuming there are two Circle objects. In comparing them we are assuming the following:
- If any one of the objects points to null, then equals() returns false.
- If both objects are of different Java class, then equals() returns false.
- If both the objects are equal, then equals() returns true.
- Otherwise, both Circle objects are considered equal if they have the same radii.
Complete the following equals() method (YOUR CODE HERE) in your Circle class to satisfy the above requirements:
@Override
public boolean equals(Object obj) {
// YOUR CODE HERE
}
Related Book For
Posted Date: