One of hundreds of answers available with our premium content service.
A: Normally when we compare two objects we use the fundamental equals(Object) method. Conceptually, the equals method "belongs" to the objects you are comparing and returns a boolean to indicate whether they are passed a reference to themselves.
Its not obvious why you would choose to make that comparison in the constructor of another class, which may only return a reference to the new instance, not a simple boolean response. In any case, the example below shows how you can compare method arguments and return a boolean, which could be refactored for use in a constructor.
… full answer hidden
Premium members click below for full answer
How can I create a constructor to equate two other objects?