Set
- Set Implementations on Oracle Tutorials
Three general-purpose implementations of the Set interface:
Use HashSet unless you need the elements to be in a certain fixed order.
List
Listinterface
Tutorial on List implementations.
General-purpose List implementations:
Map
Note that Map does not extend Collection like all the other interafaces in this document.
Mapinterface
Tutorial on Map implementations
General-purpose Map implementations:
HashMap vs. Hashtable
HashMap is a member of the Java Collections Framework.
Hashtable is an older legacy class that has been retrofitted to fit in the Java Collections Framework.
The differences between HashMap and Hashtable are:
HashMappermits anullkey andnullvalues, whereasHashtablepermits only non-nullkeys and values.HashMapis not syncrhonised, whereasHashtableis synchronised (that is, thread-safe).
Hashtable can be regarded as obsolete. If you need a synchronised HashMap, it’s better to use ConcurrentHashMap than Hashtable (see here).
Queue
Queue interface.
General-purpose implementations of Queue:
Deque
Stands for double-ended queue.
Deque interface.
General-purpose implementations:
The Java Collections Framework
- Guide on Oracle
- All the interfaces and classes that are part of the Collections Framework are listed here
| Interfaces | Hash table Implementations | Resizable array Implementations | Tree Implementations | Linked list Implementations | Hash table + Linked list Implementations |
|---|---|---|---|---|---|
Set |
HashSet |
TreeSet |
LinkedHashSet |
||
List |
ArrayList |
LinkedList |
|||
Queue |
PriorityQueue |
LinkedList |
|||
Deque |
ArrayDeque |
LinkedList |
|||
Map |
HashMap |
TreeMap |
LinkedHashMap |
All the above interfaces (except Map) implement the Collection interface.
The Collections class contains static methods that operate on objects implementing the above interfaces.