19-Collection

Опубликовано: 31 Май 2026
на канале: yogiblrithub
108
2

Collection Interface
Root interface of the collection framework.
It is a generic interface and is implemented by most of the collections.
2. Main Subinterfaces of Collection
List: An ordered collection (also known as a sequence). It allows duplicate elements.
Set: A collection that does not allow duplicate elements.
Queue: A collection used to hold multiple elements prior to processing. It typically orders elements in a FIFO (First-In-First-Out) manner.
3. Map Interface
Though not a part of the Collection interface, Map is an essential part of the Java Collection Framework.
It maps unique keys to values. A key is an object that you use to retrieve a value later. It does not allow duplicate keys.
4. Concrete Implementations
List Implementations:

ArrayList: Resizable array implementation.
LinkedList: Doubly-linked list implementation.
Vector: Synchronized resizable array implementation.
Stack: Last-In-First-Out (LIFO) stack implementation (extends Vector).
Set Implementations:

HashSet: Hash table-based implementation. No ordering.
LinkedHashSet: Hash table and linked list implementation. Maintains insertion order.
TreeSet: Tree-based implementation. Sorted according to natural order or a comparator.
Queue Implementations:

PriorityQueue: Priority heap implementation. Elements are ordered based on their natural ordering or a comparator.
Deque (Double Ended Queue):
ArrayDeque: Resizable array implementation of the deque.
LinkedList: Also implements Deque.
Map Implementations:

HashMap: Hash table-based implementation. No ordering.
LinkedHashMap: Hash table and linked list implementation. Maintains insertion order.
TreeMap: Red-Black tree-based implementation. Sorted according to natural order or a comparator.
Hashtable: Synchronized hash table-based implementation. Keys and values are hashed