What It Means if we Don\'t Override equals()

What It Means if we Don\'t Override equals()

Its a type of potential limitation.if we don\'t override equal() method.you won\'t be able to use the object as a key in a hashtable.

The equals() method in Object uses only the == operator for comparisons,so unless we override equals(), two objects are considered equal only if the two references refer to the same object.


If we would like to objects of our class to be used as keys for a Hashtable,then we must override equals() so that two different instances can be considered the same.


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