Stephan van Hulst wrote:The identity of an object is simply that. Every object you create has its own unique identity. It doesn't matter if two objects are of the same class, hold the same references, have the same values; if they were created separately, they have unique identities. If two different variables hold a reference to the same object instance, the objects will be identical.
Equality means whether two (generally unique) objects are equal. Whether they are, depends on how the class defines equality.
Let's take a look at the book class:
book1 and book2 are two different copies of the same book "Nineteen eighty-four", writter by George Orwell. They are unique. However, the book class says that they are equal, because they have the same title and author.
book3 and book1 are obviously unequal, because they have different titles and authors.
book3 and book4 are not only equal, they are also identical, because they refer to the exact same copy of a book.
Thanks it really gave me good information
----------
Now, if you remove overriding "equal" method then
System.out.println(book1.equals(book2)); // Shall it return "false" ???
----------