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 -
- ArrayList
- LinkedList
- Vector (Implemented in Stack Class)
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.
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.
3. Vector
- Vector is similar to ArrayList but it is synchronized, therefore thread-safe.
- Typically used in multi-thread operation.
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.
0 Comments