All Classes of List Interface (ArrayList, LinkedList, Vector, and Stack)

 In Java, the List interface is the fundamental part of the Collection Framework. It is offered ordered collection that supports dynamic resizing and duplicate support. This blog explains just the core characteristics of the classes (ArrayList, LinkedList, Vector, and Stack) of List interface. And compare among them based on uses.

Classes Implemented the List Interface

  1. ArrayList
  2. LinkedList
  3. Vector (Implemented in Stack Class)

All classes of List Interface (ArrayList, LinkedList, Vector, and Stack)
Classes of List Interface

1. ArrayList Class
  • ArrayList can fast access to search and iterate in a list.
  • This is not synchronized, and not thread-safe.
Recommended to use when requiring fast access to search and iterate the list but thread-safe is not a concern.

ArrayList Example

2. LinkedList
  • Uses a doubly linked list structure.
  • Typically, use to frequently add and remove data from the list.
  • This is not synchronized, and not thread-safe.
LinkedList Code Example

3. Vector
  • Vector is similar to ArrayList but it is synchronized, therefore thread-safe.
  • Typically used in multi-thread operation.
Vector Code Example

4. Stack 
Stack does not extend the List interface. It extends the Vector class. Therefore,
  • Stack is synchronized and thread-safe.
  • It follows LIFO (Lirst-In-First-Out) concept.
  • Typically used for undo operation.
Stack Code Example


Post a Comment

0 Comments