The Java collections framework is a set of classes and interfaces that implement commonly reusable collection data structures 2
3
LIST inTERfACE The List interface in Java provides a way to store the ordered collection . In this interface we can have control over where in the list each element is inserted. The elements in the list can be accessed by their integer index (position in the list), and search for elements in the list. Lists allow duplicate elements The List.of and List.copyOf static methods that provide a way to create unmodifiable lists 4
Abstract LIST class This class provides a skeletal implementation of the List interface for Random Access , Where as AbstractSequenceList class is used when sequential access is required add (int index, E element) add (E e) remove (int index) set (int index, E element) 5
6
ArrayList Resizable-array implementation of the List interface. Implements all optional list operations, and permits all elements, including null. In addition to implementing the List interface, this class provides methods to manipulate the size of the array that is used internally to store the list. It is not Synchonized CopyOnWriteArrayList , is a thread-safe variant of ArrayList . 7
8
linkedList Linked List is a part of the Collection framework present in java.util package. This class is an implementation of the LinkedList data structure which is a linear data structure where the elements are not stored in contiguous locations. Every element is a separate object with a data part and address part. The elements are linked using pointers and addresses. Each element is known as a node. 9
10
Vector Vector implements a dynamic array which means it can grow or shrink as required. They are very similar to ArrayList , but Vector is synchronized and has some legacy methods that the collection framework does not contain. It also maintains an insertion order like an ArrayList . Still, it is rarely used in a non-thread environment as it is synchronized, and due to this, it gives a poor performance in adding, searching, deleting, and updating its elements. 11
STACK Java Collection framework provides a Stack class that models and implements a Stack data structure. The class is based on the basic principle of last-in-first-out. In addition to the basic push and pop operations, the class provides three more functions of empty, search, and peek. 12