List has three sub classes : 1] ArrayList 2] LinkedList 3] Vector
Set has two direct sub class : 1] HashSet 2] LinkedHashset
Set also has one indirect sub class , I mean to say it has a interface SortedSet & it has one sub class TreeSet .
Now come to Map , Although we call it collection but it has no relation with Collection .
Map - interface
It has 3 direct classes :
1] Hashtable 2] HashMap 3] LinkedHashMap
It also has one interface SortedMap that has one sub class TreeMap ( same like TreeSet )
Now total we have 10 collections . I am explaning all 10 in short , if you want more detail then specify that , I will again try to provide ...
All List has index-value pair . So all are ordered by index . 1] ArrayList => growable array , nothing special in this . 2] Vector => same as ArrayList but all the methods are synchronized in this case . 3] LinkedList => if you read data structure in your syllabus then probably you would be familiar with this . All element has two link , one is towords right element & one is towords left element .
Set just store one object in one row , no pair ( index-value , key-value ) type of thing in this . you can think like it just store values . They doesn't allow duplications . 1] HashSet => nothing special , not sorted , no order . 2] LinkedHashSet => not sorted ( only TreeSet is sorted ) yes but you can retrive values with insertion order or last access order . 3] TreeSet => sorted .
Map have key-value pair in one row . both are object . key should be unique in Map . 1] HashMap => nothing special , not sorted , no order . 2] Hashtable => same as HashMap , but mthods are synchronized here . 3] LinkedHashMap => same as LinkedHashSet , maintain order . 4] SortedMap => sorted .
Some Twos : 1] two collection have synchronized method : Vector , Hashtable ( both were in 1.2 also ) 2] two collection are sorted : TreeSet , TreeMap
One Three :
3] three collection have elements that have two link : LinkedList , LinkedHashSet , LinkedHashMap
I hope I didn't miss anything important in this . If missed then please put ... [ February 04, 2005: Message edited by: rathi ji ]
Originally posted by shandilya popuru: great explanation rathi ji
and the links provided by jay pawar were really helpful
thanks a lot, i was weak in collections framework and k&b doesnt go into the implementation of them or the api, those links had everything i wanted
Honestly... , if you are just targeting to clear the SCJP 1.4 exam. K&B book is more than sufficient. You do not have to memorize the API for each of the interface. Just keep in mind Set do not allow duplicates and List do. The table in the collection chapter of K&B book is all you should know to tackle the questions in the exam.
The links I provided will definitely give you more knowledge than what is intended for clearing the exam. The choice is yours..
Hope that helps
Cheers,<br />Jay<br /> <br />(SCJP 1.4)<br />Heights of great men were not achieved in one day, they were toiling day and night while their companions slept.