Java collections framework is a unified architecture for representing and manipulating collections. All collections frameworks contain the following:
Interfaces: These are abstract data types that represent collections. Interfaces allow collections to be manipulated independently of the details of their representation. In object-oriented languages, interfaces generally form a hierarchy.
Implementations, i.e., Classes: These are the concrete implementations of the collection interfaces. In essence, they are reusable data structures.
Algorithms: These are the methods that perform useful computations, such as searching and sorting, on objects that implement collection interfaces. The algorithms are said to be polymorphic: that is, the same method can be used on many different implementations of the appropriate collection interface.
In addition to collections, the framework defines several map interfaces and classes. Maps store key/value pairs. Although maps are not collections in the proper use of the term, but they are fully integrated with collections.
Related Tags
Tutorials
Initialize a Java List in one line with List.of() for an unmodifiable list, or new ArrayList<>(List.of(…)) when the list changes later. Compare Arrays.asList(), Stream.toList(), Collections and Guava by mutability and null support.
Learn to initialize HashMap in Java with Map.of, newHashMap and streams, and see how initial capacity and load factor decide when the map resizes.
Iterator vs ListIterator vs Spliterator in Java compared in one table, with Enumeration, fail-fast rules, examples and when to use each cursor.
Learn to sort ArrayList in Java in ascending and descending order with List.sort(), Comparator.reverseOrder(), Collections.sort() and streams.
Learn how Java Map computeIfAbsent() works, with multimap and cache examples, null and exception rules, thread safety and the putIfAbsent() difference.
Java ConcurrentSkipListMap keeps keys sorted for many threads. Learn skip lists, floor and ceiling keys, live range views, polling and TreeMap differences.
Find the max value in a Java Map and its key with streams, Collections.max() or one loop, and handle min values, ties, empty maps and null values safely.
Assert two lists equal ignoring order with AssertJ, Hamcrest, Commons Collections or plain JUnit 6, and see which assertions count duplicates.
java.lang.UnsupportedOperationException means the code tried to change a collection that cannot be changed, such as one from Arrays.asList(), List.of() or Collections.unmodifiableMap(). Copy the data into an ArrayList or HashMap to fix it.
Java ArrayDeque tutorial with stack and queue examples, both-end methods, Java 21 reversed(), iteration, an undo history and ArrayDeque vs LinkedList.
Java SynchronousQueue explained with put(), take(), offer() and poll() examples, a producer-consumer handoff, thread pool use and the alternatives.
Java Queue interface guide with the six methods, how to choose ArrayDeque, PriorityQueue or a BlockingQueue, iteration, BFS and thread-safe queues.
Convert a map to a list, array or set in Java using keySet(), values() and entrySet(), with streams, toArray(), ordering rules and lists of records.
Learn to flatten a list of lists in Java with flatMap(), addAll() loops, mapMulti(), recursion for deep nesting, Guava and Eclipse Collections.
Convert List to Map in Java with Collectors.toMap() and groupingBy(), fix the duplicate key IllegalStateException with a merge function, keep order.
Arrays.asList() vs new ArrayList() in Java explained with examples, covering fixed size, the shared array, List.of(), primitive arrays and conversions.
Invert a map in Java by swapping keys and values with a loop or Collectors.toMap(), handle duplicate values with groupingBy(), and use Guava BiMap.
Java HashMap guide with examples for put, get, merge, compute, iteration, keys, internals and thread safety, plus links to every HashMap how-to.
Learn the Java Collections Framework with a Java 21 hierarchy diagram, how to choose List, Set, Map and Queue classes, and links to every tutorial.
Learn the Java ArrayList with tested examples for get(), size() vs capacity, subList(), ensureCapacity(), sorting, streams and Java 21 getFirst().
The Java List interface explained with examples of List.of(), positional methods, Java 21 sequenced methods and how to choose an implementation.
A Java Map stores unique keys with one value each. Quick put/get/merge/computeIfAbsent examples, a comparison of HashMap, LinkedHashMap, TreeMap, ConcurrentHashMap, EnumMap, Hashtable and Map.of(), and all our Map tutorials grouped by topic.
Create a Java case insensitive map with TreeMap and CASE_INSENSITIVE_ORDER, Commons CaseInsensitiveMap or Spring LinkedCaseInsensitiveMap, side by side.
Java EnumMap stores enum keys in an array by ordinal. Learn its constructors, null rules, key order, stream collectors and how it differs from HashMap.
Create a Java nested map with computeIfAbsent and streams, add, remove and iterate entries, read values safely, deep copy, flatten and choose alternatives.
Immutable vs unmodifiable map in Java explained with Map.of(), Map.copyOf(), Collections.unmodifiableMap(), toUnmodifiableMap() and Guava ImmutableMap.
Collect stream to immutable list in Java with toList() or Collectors.toUnmodifiableList(), how nulls differ, plus unmodifiable Set and Map collectors.
TreeMap vs HashMap in Java compared on ordering, speed, null keys, memory and key equality, with Java 25 examples and a table for picking the right map.
Java IdentityHashMap compares keys with == instead of equals(). Learn how it differs from HashMap, the String and Integer traps and the Java 20 change.
Java ConcurrentMap with putIfAbsent, compute and merge examples, why get-then-put loses updates, null rules and ConcurrentHashMap vs ConcurrentSkipListMap.
Learn how Java WeakHashMap removes entries after GC clears weak keys, the String and value-reference traps, WeakHashMap vs HashMap and real use cases.
Java forEach() on List, Set and Map with Consumer and BiConsumer, iteration order, forEach vs for loop, break and ConcurrentModificationException
Java CopyOnWriteArraySet explained with examples, snapshot iteration, O(n) costs, a chat room use case and a comparison with ConcurrentHashMap.newKeySet().
Learn how Java CopyOnWriteArrayList copies its array on writes, why its iterators never fail, addIfAbsent(), Java 21 methods and when to use it.
Java TransferQueue and LinkedTransferQueue explained with transfer(), tryTransfer() and put() examples, timeouts, and a comparison with SynchronousQueue.
Java ArrayBlockingQueue examples covering put, offer, take, fairness, producer-consumer threads and batch draining with drainTo(), vs LinkedBlockingQueue.
Java PriorityBlockingQueue examples with Comparator, take(), drainTo() and a print-server worker, plus how it differs from PriorityQueue and DelayQueue.
Java priority queue tutorial with PriorityQueue examples for natural order, Comparator, max-heap, equal priorities and top K, and why it prints unsorted.
Java Spliterator examples for tryAdvance(), trySplit(), characteristics and estimateSize(), plus batching, fork/join and a custom Spliterator.
Java ListIterator examples for forward and backward traversal, listIterator(index), cursor positions and the rules for add(), set() and remove().
Java Iterator explained with hasNext(), next(), remove() and forEachRemaining(), how modCount causes ConcurrentModificationException, and Enumeration.
Java Comparator interface with lambdas, comparing(), thenComparing(), reversed() and nullsFirst(), plus sorting by multiple fields in Java 25.
Learn the Java Comparable interface with compareTo() examples, the contract rules, the subtraction and equals() traps, and natural order in records.
Learn the Java LinkedList class with examples. List and Deque methods, an undo stack, Java 21 reversed(), real time complexity and when to use it.
Learn Java TreeSet with examples. Sorting with comparators, floor() and ceiling(), range views, the compareTo() duplicate trap and Java 21 methods.
Learn Java LinkedHashSet with examples. Keep insertion order, remove duplicates, and use Java 21 getFirst(), addFirst() and reversed() on a SequencedSet.
Learn Java HashSet with examples. How it detects duplicates, equals() and hashCode(), set operations, newHashSet(), performance and HashSet vs TreeSet.
Java Hashtable is a synchronized legacy map. See how it works, why compound updates still race, HashMap vs Hashtable, and when to use ConcurrentHashMap.
Java TreeMap keeps keys sorted in a red-black tree. Learn comparators, floorKey(), ceilingKey(), subMap(), headMap(), tailMap() views and null key rules.
Java LinkedHashMap keeps keys in insertion or access order. See SequencedMap methods from Java 21 and build an LRU cache with removeEldestEntry().