In this article, we will discuss the Java collection framework hierarchy with diagrams. In this article, we will be focusing only on the collection framework hierarchy and if you want to learn Java collections framework in-depth then visit the below tutorial:
The following concurrent-aware implementation classes are available. See the API documentation for the correct usage of these implementations.
Learn all about collection framework at Java Collections Framework in Depth with Examples for BeginnersA collections framework is a unified architecture for representing and manipulating collections, enabling collections to be manipulated independently of implementation details.
What is a Collections Framework?
A collections framework is a unified architecture for representing and manipulating collections.
The collections framework consists of:
- Collection interfaces - These interfaces represent different types of collections, such as Set, List, and Map. These interfaces form the basis of the framework.
- General-purpose implementations - These are primary implementations of the collection interfaces such as ArrayList, LinkedList, HashSet, LinkedHashSet, HashMap etc.
- Legacy implementations - The collection classes from earlier releases, Vector and Hashtable, were retrofitted to implement the collection interfaces.
- Special-purpose implementations - Implementations designed for use in special situations such as CopyOnWriteArrayList, CopyOnWriteArraySet, EnumSet, EnumMap, WeakHashMap and IdentityHashMap etc.
- Concurrent implementations - These implementations designed for highly concurrent use such as ConcurrentSkipListSet, ConcurrentHashMap, ConcurrentSkipListMap etc.
- Wrapper implementations - Add functionality, such as synchronization, to other implementations.
- Convenience implementations - High-performance "mini-implementations" of the collection interfaces.
- Abstract implementations - Partial implementations of the collection interfaces to facilitate custom implementations such as AbstractCollection, AbstractSet, AbstractList, AbstractSequentialList and AbstractMap.
- Algorithms - Static methods that perform useful functions on collections, such as sorting a list.
- Infrastructure - Interfaces that provide essential support for the collection interfaces.
- Array Utilities - Utility functions for arrays of primitive types and reference objects. Not, strictly speaking, a part of the collections framework, this feature was added to the Java platform at the same time as the collections framework and relies on some of the same infrastructures.
Java Collections Framework Hierarchy
Let us see the hierarchy of Collection framework. The java.util package contains all the classes and interfaces for the Collection framework.
The collection interfaces are divided into two groups. The most basic interface, java.util.Collection interface has the following descendants and it's implementations:
The other collection interfaces are based on java.util.Map and it's implementations:
The other collection interfaces are based on java.util.Map and it's implementations:
1. Collection Interfaces
The collection interfaces are divided into two groups. The most basic interface, java.util.Collection has the following descendants:- java.util.Collection
- java.util.List
- java.util.Set
- java.util.SortedSet
- java.util.NavigableSet
- java.util.Queue
- java.util.concurrent.BlockingQueue
- java.util.concurrent.TransferQueue
- java.util.Deque
- java.util.concurrent.BlockingDeque
- java.util.Map
- java.util.SortedMap
- java.util.NavigableMap
- java.util.concurrent.ConcurrentMap
- java.util.concurrent.ConcurrentNavigableMap
2. Collection Implementations
Classes that implement the collection interfaces typically have names in the form of [Implementation-style][Interface] ( example: [Hash][Set]].
The general-purpose implementations are summarized in the following table:
The general-purpose implementations are summarized in the following table:
The AbstractCollection, AbstractSet, AbstractList, AbstractSequentialList, and AbstractMapclasses provide basic implementations of the core collection interfaces, to minimize the effort required to implement them.
3. Concurrent Collections
Applications that use collections from more than one thread must be carefully programmed. In general, this is known as concurrent programming. The Java platform includes extensive support for concurrent programming.
These concurrent-aware interfaces are available:The following concurrent-aware implementation classes are available. See the API documentation for the correct usage of these implementations.
- LinkedBlockingQueue
- ArrayBlockingQueue
- PriorityBlockingQueue
- DelayQueue
- SynchronousQueue
- LinkedBlockingDeque
- LinkedTransferQueue
- CopyOnWriteArrayList
- CopyOnWriteArraySet
- ConcurrentSkipListSet
- ConcurrentHashMap
- ConcurrentSkipListMap
Learn collection interfaces with its implementations in-depth
You can learn everything about the Java collections framework here. Check out each article, tutorials, guides below gives you a hands-on experience.
Interfaces
- Collections Framework - The Collection Interface
- Collections Framework - The Set Interface
- Collections Framework - The SortedSet Interface
- Collections Framework - The List Interface
- Collections Framework - The Queue Interface
- Collections Framework - The Deque Interface
- Collections Framework - The Map Interface
- Collections Framework - The SortedMap Interface
List Implementations
General-Purpose List Implementations:
- Collections Framework - ArrayList Class // Popular
- Collections Framework - LinkedList Class // Popular
Special-Purpose List Implementations:
Set Implementations
General-Purpose Set Implementations:
Special-Purpose Set Implementations:
Map Implementations
General-purpose Map Implementations:
- Collections Framework - HashMap Class
- Collections Framework - LinkedHashMap Class
- Collections Framework - TreeMap class
Special-Purpose Map Implementations:
Sorting
Aggregate Operations(Streams)
Collections Helper/Utility Classes
- java.util.Collections Class API Guide(Development)
- 18 Useful Collections Utility Methods (Development)
- Java CollectionUtils Class(Development)
Convert Collections Examples
- Conversion Between Array and Set in Java
- Conversion Between Array and List in Java
- Java Convert Map to Set Example
- Java Convert Map to List Example
- Java Convert Map to Array Example
- Convert a Map to an Array, List and Set in Java
- Java 8 Convert List to Map Example
- Java 8 - Merging Two Maps Example
- Java Convert Array to String [Snippet]
Collections Examples
- Different Ways to Iterate over List, Set and Map in Java
- Java Comparator Interface Example
- Java Comparable Interface Example
- Java IdentityHashMap Example
- Java WeakHashMap Example
- Java EnumMap Example
- Java CopyOnWriteArraySet Example
- Java EnumSet Class Example
- Guide to Java 8 forEach Method
- Different Ways to Iterate over a List in Java [Snippet]
- Different Ways to Iterate over a Set in Java [Snippet]
- Different Ways to Iterate over a Map in Java [Snippet]
Collections Differences
- Difference between LinkedList vs ArrayList in Java
- Difference between List and Set in Java Collection
- Difference between Stack and Queue Data Structure in Java
- Difference between HashMap and HashSet in Java
- Difference between TreeSet, LinkedHashSet, and HashSet in Java with Example
- Difference between EnumMap and HashMap in Java
- Difference between HashMap and HashSet in Java
- Difference between ArrayList and Vector in Java
- Difference between HashMap, LinkedHashMap, and TreeMap in Java
- Difference between PriorityQueue and TreeSet in Java?
- What is the difference between Enumeration and Iterator in Java?
- What is the difference between HashMap and Hashtable in Java?
- Difference between fail-fast Iterator vs fail-safe Iterator in Java
Best Practices and Interviews
- Java Collection Framework Best Practice (Best Practice)
- Difference between Array vs ArrayList in Java (interview)
- How the Size of the ArrayList Increases Dynamically? (interview)
- How To Remove Duplicate Elements From ArrayList In Java? (interview)
Free Spring Boot Tutorial | Full In-depth Course | Learn Spring Boot in 10 Hours
Watch this course on YouTube at Spring Boot Tutorial | Fee 10 Hours Full Course