The following table summarizes the principal classes in Java collections framework for quick reference:

Main collection classes

D

O

S

TS

ArrayList

Yes

Yes

No

No

LinkedList

Yes

Yes

No

No

Vector

Yes

Yes

No

Yes

HashSet

No

No

No

No

LinkedHashSet

No

Yes

No

No

TreeSet

No

Yes

Yes

No

HashMap

No

No

No

No

LinkedHashMap

No

Yes

No

No

Hashtable

No

No

No

Yes

TreeMap

No

Yes

Yes

No

 

  • D: Duplicate elements is allowed?
  • O: Elements are ordered?
  • S: Elements are sorted?
  • TS: The collection is thread-safe?

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 TreeSet and TreeMap – which sort elements by natural order or by a comparator.
    •           Generally, elements within sets and maps are not ordered, except for:
        •    LinkedHashSet and LinkedHashMap have elements ordered by insertion order.
        •       TreeSet and TreeMap have elements ordered by natural order or by a comparator.
    •           There are only two collections are thread-safe: Vectorand Hastable. The rest is not thread-safe.

 

Java Collections Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Attachments:
Download this file (java_collections_framework_summary.pdf)java_collections_framework_summary.pdf[Summary of the java collections framework]132 kB

Add comment

   


Comments 

#10Saeed2022-12-21 02:15
Quoting Nam:
Quoting Pankaj:
What is the difference between ordered and sorted

Ordered and Sorted are the same.

Ordered are insertion order preserved and it may not be same as sorted.
Quote
#9Juan2022-11-10 03:20
Ordered should be Positioned
Quote
#8Sukanta Biswas2020-06-16 15:24
Order of insertion and sort are not same. as order may not be sorted.
Quote
#7Victor2019-09-24 20:11
Quoting Nam:
Quoting Pankaj:
What is the difference between ordered and sorted

Ordered and Sorted are the same.

Ordered means it will maintain the insertions order. So you will get the same value every time. Sorted means elements will be sorted on ascending order A to Z
Quote
#6Pankaj2017-11-27 22:17
Quoting Nam:
Quoting Pankaj:
What is the difference between ordered and sorted

Ordered and Sorted are the same.

they why we have separate columns.
Quote