Collection
General info
- A collection is a single object representing a group of objects known as its elements.
- Six collection interfaces: Collection, Set, List, SortedSet, Map, SortedMap.
- Set
- List
- Vector
- Vector vs. ArrayList
- Map
Return to top
Set
- A group of objects with no duplication
- SortedSet -- subinterface of Set
- TreeSet -- sorted
- HashSet-- best performance, unordered.
- LinkedHashSet-- since jdk 1.4
Return to top
List
- A subinterface of Collection
- A group of objects with duplicate elements
- ArrayList -- like Vector, but its methods are not synchronized.
- LinkedList -- quick sequential access.
Return to top
Vector
- Has been retrofitted to implement List interface.
- Provides methods for working with dynamic arrays of varied element types.
- Its methods are synchronized.
- Slower access.
Return to top
Vector vs. ArrayList
- one slower, the other faster
- one has synchronized methods by default, the other is not.
- prefer ArrayList
Return to top
Map
- Maps keys and values.
- Hashtable -- historical implementation.
- SortedMap
- HashMap
- TreeMap
- LinkedHashMap
- IdentityHashMap
- WeakHashMap
Return to top