Overriding equals()

Overriding equals()

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

Post Your Answers


User Email:

User Name:
Answers:

Related scjp1.5 chap8 Links

scjp1.5 chap8 interview questions and answers for experienced and fresher