How to get the unique ID of an object which overrides hashCode()?

When a class in Java doesn’t override hashCode(),
printing an instance of this class gives a nice unique number.

The Javadoc of Object says about hashCode():

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects.

But when the class overrides hashCode(), how can I get
its unique number?

10 Answers
10

Leave a Comment