The java.util package

30) Make appropriate selection of collection classes/interfaces to suit specified behavior requirements.

java.util package has utility classes covering six basic areas namely - Collections, i18n, Calendar, Jarfiles, Zipfiles, other
Note : Discussed only collection classes/interfaces.
General area Interface/Abstract class concrete class
Collections Collection (basic access and update functions)
Set HashSet(a set of values built on a hash table)
TreeSet ( a set in sorted order)
List ArrayList (use instead of Vector)
LinkedList
Map HashMap (use instead of Hashtable)
TreeMap (a map in sorted order)
WeakHashMap (a table whose entries go away. When the thing they refer to is garbage collected)
Other Stack, Array, BitSet, Iterator(replaces Enumerator)

Collection :

interface Set


HashSet implements the Set interface and extends AbstractSet

TreeSet : java.util.List : ArrayList implements List extends AbstractList : java.util.Map : HashMap implements Map extends AbstractMap: Others :

BitSet :

Stack : Iterator :


Hints to choose between Collection classes :

Remember :




Copyright © 1999-2000, Jyothi Krishnan
All Rights Reserved.