José Iêdo

A summary about java collections apis

July 17, 2025
2 min read
Table of Contents

I’m studying for Java SE 17 certification and I noticed already how much I need to memorize, but I don’t like to memorize… Here is my try to remember the interfaces of java collections. I may update or not if I remember…

Array → ArrayList, ArrayDeque

  • Pattern: Direct array backing
  • Implication: Fast random access, resizing overhead

Hash → HashMap, HashSet, LinkedHashMap, LinkedHashSet

  • Pattern: Hash table + bucket array
  • Implication: O(1) average operations, no ordering guarantees (except Linked*)

Linked → LinkedList, LinkedHashMap, LinkedHashSet

  • Pattern: Doubly-linked list structure
  • Implication: Maintains insertion/access order, sequential access

Sorted → SortedMap, SortedSet

  • Pattern: Interface for natural ordering
  • Implication: Elements kept in sorted order
  • Pattern: interfaces with Sorted + navigation methods (extends Sorted*)
  • Key methods: lowerKey(), higherKey(), floorKey(), ceilingKey()
  • Mental model: “Find me the closest element to X”

Tree → TreeMap, TreeSet

  • Pattern: Red-black tree implementing Navigable*
  • Implication: O(log n) operations, sorted + navigable

Blocking → BlockingQueue, BlockingDeque

  • Pattern: interfaces for Queue + thread coordination
  • Implication: put() blocks when full, take() blocks when empty

Transfer → TransferQueue

  • Pattern: interface Blocking + producer-consumer handoff
  • Bonus: transfer() waits for consumer to receive

Concurrent → ConcurrentHashMap, ConcurrentSkipListMap

  • Pattern: Thread-safe without external synchronization
  • Implication: Higher overhead, but no Collections.synchronizedX() needed