Tuesday, 9 January 2018

What are the classes implementing List interface?

We have three classes implementing list interface in java Collection framework hierarchy. Look at the diagram given below:

list interface java radar



From the diagram its clear that classes implementing list interface are:


1. ArrayList
  • Arraylist was added in Java 1.2 version.
  • Arraylist uses grow able array and thus can grow automatically.
  • Arraylist in java is not synchronized or thread safe.
  • As arraylist is non-synchronized so it is better performance wise as multiple threads can access the resources of arraylist at the same time simultaneously.
  • Arraylist's  iterator and list iterator are fail fast in nature.
  • Follow the link to read in detail about arraylist

Read: Why iterator on arraylist is fail fast in java?


2. LinkedList
  • Linkedlist was added in Java 1.2 version
  • Linkedlist in java is not synchronized
  • Linkedlist stores element in nodes which has capability to store element and its address.
  • Follow the link to read in detail about linkedlist

Read: Difference Arraylist vs Linkedlist


3. Vector
  • Vector is synchronized in nature. This is the major difference between array list and vector.
  • Vector is a legacy class and is not recommended to be used at present.
  • Follow the link to read in detail about vector


You may also like to read about:

No comments:

Post a Comment

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
If you are looking for a reference book on java then we recommend you to go for → Java The Complete Reference
Click on the image link below to get it now.