Google News
logo
Java Collections - Interview Questions
What is the difference between List and Set?
The List and Set both extend the collection interface. However, there are some differences between the both which are listed below.
 
* The List can contain duplicate elements whereas Set includes unique items.
* The List is an ordered collection which maintains the insertion order whereas Set is an unordered collection which does not preserve the insertion order.
* The List interface contains a single legacy class which is Vector class whereas Set interface does not have any legacy class.
* The List interface can allow n number of null values whereas Set interface only allows a single null value.
Advertisement