Differences between Set & List -Collections in java

Set:
Set does not allow duplicate values.
Set is an unordered collection.
Set implementations: HashSet, LinkedHashSet, TreeSet etc.
Set can have only a single null value at most.

List:
List is an ordered collection it maintains the insertion order
List allows duplicates
List implementations: ArrayList, LinkedList etc.
List allows any number of null values

No comments:

Post a Comment