What is the difference between Set and List interface?

What is the difference between Set and List interface?

A set interface is an unordered collection of elements that cannot contain duplicate elements. Whereas list is an unordered collection and thus elements can be inserted and deleted based upon the order in which they were lined. The differences between the two are :



Set is an unordered collection i.e it does not maintain elements as per their insertion order.

List is an ordered collection. The elements in list are displayed in their insertion order.

Set does not allow duplicate elements.

List allows duplicate elements to be entered.

Implementations of set : Hash Set, Linked Hash Set etc.

Implementations of List : Array List, Linked List etc.

There can only be one null value in Set.

There can be any number of null values in List.

To move up and down(forward or backward) in Set, Iterator is used.

Whereas, in List to move ListIterator is used.

Set doesn't have any legacy classes.

List has one legacy class called Vector.

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.