| Author |
Doubts on Collection framework
|
janki tangeda
Ranch Hand
Joined: Jun 07, 2005
Posts: 54
|
|
(from scjp book)Objects of class that override the equals() method are used in a collection.If they override the hashcode() method they can also be used as elemens in HashSet and keys in HashMap. Q.1)Is it required that the above conditions be met for Objects to be included in a particular type of collection/Map? Q.2)Is overriding hashcode() method is also enough for the objects to be elements of HashTable/LinkedHashSet/LinkedHashMap??? (from scjp book)Implementing the Comparable interface allows them to be used as elements in sorted sets & sorted maps. Q.3)Can the elements of sorted sets & maps implement Comparator interface instead of Comparable interface? (from scjp book)A Comparator interface is used to impose total ordering on the elements and a Comparable interface for natural ordering. Q.3)I didn't get what these terms 'total ordering' & 'natural ordering' mean?can anybody explain.
|
 |
 |
|
|
subject: Doubts on Collection framework
|
|
|