Differentiate between List and Set?

Difference between List and Set in Java

List and Set both are interfaces provides in java.util package

Some of the different between them are


  • List is a type of ordered collection that maintains the elements in insertion order while Set is a type of unordered collection so elements are not maintained any order. 
  • List allows duplicates while Set doesn't allow duplicate elements



Comments

Popular posts from this blog

What is template?

Can we access private members of an instance?

What are wrapper classes in Java?