The Java collection framework is very powerful and includes numerous capabilities such as cloning, return values, removing elements, and more.
The following table summarizes the principal classes in Java collections framework for quick reference:
From this table we can conclude the following characteristics of the main collections in Java Collection Frameworks:
- All lists allow duplicate elements which are ordered by index.
- All sets and maps do not allow duplicate elements.
- All list elements are not sorted.
- Generally, sets and maps do not sort its elements, except
TreeMap – which sort elements by natural order or by a comparator.
- Generally, elements within sets and maps are not ordered, except for:
LinkedHashMap have elements ordered by insertion order.
TreeMap have elements ordered by natural order or by a comparator.
- There are only two collections are thread-safe:
Hastable. The rest are not thread-safe.