Originally posted by Rajiv Goyal:
hi,
1)what is difference between the two ie heap and stack in java terminology
2)Can someone summarize as different collections (like treest,linkedlist etc )are used/useful for under what circumstances
thanks,
Rajiv
[ August 25, 2003: Message edited by: Rajiv Goyal ]
set: stores unique elements but not ordered.
linkedhashset: they r ordered and unique.It doesn't delete least recently used element when new is added.
Implementation of set is hashset.
list: elements are in ordered but not unique. They can contain duplicates.
Implementation of list are Arraylist,linkedlist and vector.
vector is thread safe but arraylist is not.
when searching some element arraylist and vector r giving good performance. but linkedlist not since we have to traverse each element.
But at the time of insertion and deletion linked list is preferred.
map: contains the elements in key value pair.
Implementations are hashmap and hashtable.
hashmap is not thread safe and can contain null elements.
hashtable is thread safe and can not contain null elements.
linkedhashmap : It deletes least recently used element when new is added.
and can contain nulls. elements i.e.keys are in order.