This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Doubts on Collection framework Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Doubts on Collection framework" Watch "Doubts on Collection framework" New topic
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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Doubts on Collection framework
 
Similar Threads
Java API
Set interface in K&B SCJP book
Comparable
Vector.
Difference between a Comparator &Comparable