What is difference between List, Set and Map

1. What is difference between List, Set and Map?


  • List is an ordered collection.
  • List allows duplicate elements.
  • List allows null elements and also store many null elements because it allows duplicate elements.

The following most useful classes implementing List interface

1. ArrayList  2. LinkedList  3. Vector


  • Set is unordered collection.
  • Set does not allows duplicate elements.
  • Set just allow one null element and does not allow more than one null element.

The following most useful classes implementing Set interface

1. HashSet  2. LinkedHashSet 3. TreeSet


  • Map is unordered collection
  • Map hold two objects per Entry e.g. Key and Value and it may contain dupliate values but not keys
  • Map allow only one null key and multiple null values.

The following most useful classes implementing Map interface

1. HashMap 2. LinkedHashMap 3. Hashtable  4. TreeMap

2. When to use List, Set and Map ?


  • Frequently accessing elements by using index. Its implementation ArrayList is faster access if you know the index
  • To store duplicate elements with order.


  • To store unique data elements.


  • To store data in the form of  Key and Value.

3. What is difference between ArrayList, Vector and LinkedList?


  • It is not thread-safe by default
  • It is not synchronized by default
  • Better performance in case of single thread
  • Collections.synchronizedList using this method we can make .synchronized ArrayList is equivalent of Vector.

The Author


Hello! I am Narayanaswamy founder and admin of narayanatutorial.com. I have been working in IT industry more than 7 years. NarayanaTutorial is my web technologies blog. My specialties are Java / J2EE, Spring, Hibernate, Struts, Webservices, PHP, Oracle, MySQL, SQLServer, Web Hosting and Website Development. I am a self learner and passionate about training and writing. I am always trying my best to share my knowledge through my blog.

Leave a Reply