Now we discuss to how comparing the two object references using the == operator evaluates true only when both references refer to the same object.We saw that the String class and the wrapper classes have overridden the equals() method. so that we could compare two different objects to see if their contents are meaningfully equivalent.
When we really need to know if two references are identical, use ==. But when we need to know if the objects themselves are equal, use the equals() method. For each class we write, we must decide if it makes sense to consider two different instances equal.For some classes, we might decide that two objects can never be equal.
By:umang
Date:2013-03-09 00:00:00
Overriding hashCode() and equals()
What It Means if we Don\'t Override equals()
Implementing an equals() Method
So What Do we Do with a Collection?
Key Interfaces and Classes of the Collections Framework
Overview of Memory Management and Garbage Collection
Overview of Java\'s Garbage Collector
When Does the Garbage Collector Run?
How Does the Garbage Collector Work?
Reassigning a Reference Variable