Java Reference

Java Collections Cheat Sheet

A responsive HTML conversion of the supplied one-page Java Collections Cheat Sheet, preserving its collection comparison, performance, and notable-library information.

Source: The supplied cheat sheet compares collection classes by data support, ordering, random access and thread-safe alternatives, and provides Big-O reminders plus notable Java collection libraries. fileciteturn2file0L2-L18

Notable Java Collections Libraries

Fastutil

http://fastutil.di.unimi.it/

Fast & compact type-specific collections for Java. Great default choice for collections of primitive types, like int or long. Also handles big collections with more than 2³¹ elements well.

Guava

https://github.com/google/guava

Google Core Libraries for Java 6+. Perhaps the default collection library for Java projects. Contains a magnitude of convenient methods for creating collections, like fluent builders, as well as advanced collection types.

Eclipse Collections

https://www.eclipse.org/collections/

Features you want with the collections you need. Previously known as gs-collections, this library includes almost any collection you might need: primitive type collections, multimaps, bidirectional maps and so on.

JCTools

https://github.com/JCTools/JCTools

Java Concurrency Tools for the JVM. If you work on high throughput concurrent applications and need a way to increase your performance, check out JCTools.

What Can Your Collection Do for You?

Collection classThread-safe alternative Individual elementsKey-value pairsDuplicate element supportPrimitive support FIFOSortedLIFOPerformant contains check By keyBy valueBy index
HashMapConcurrentHashMap
HashBiMap (Guava)Maps.synchronizedBiMap
ArrayListMultimap (Guava)Maps.synchronizedMultiMap
LinkedHashMapCollections.synchronizedMap
TreeMapConcurrentSkipListMap
Int2IntMap (Fastutil)
ArrayListCopyOnWriteArrayList
HashSetCollections.newSetFromMap
IntArrayList (Fastutil)
PriorityQueuePriorityBlockingQueue✓**
ArrayDequeArrayBlockingQueue✓**✓**
The original source marks certain operations with footnotes: * O(log(n)) complexity while the other listed operations are O(1), and ** applies when using Queue interface methods such as offer() / poll(). fileciteturn2file0L81-L81

How Fast Are Your Collections?

Collection classRandom access by index / keySearch / ContainsInsert
ArrayListO(1)O(n)O(n)
HashSetO(1)O(1)O(1)
HashMapO(1)O(1)O(1)
TreeMapO(log(n))O(log(n))O(log(n))
Big-O reminder:
  • O(1) — constant time; performance does not depend on collection size.
  • O(log(n)) — logarithmic time; very fast even for large collections.
  • O(n) — linear time; operation cost grows with collection size.
These explanations are based on the source cheat sheet. fileciteturn2file0L6-L17

Original PDF Reference

The original one-page visual is preserved below so the comparison matrix and original layout remain available alongside the converted HTML version.

Original Java Collections Cheat Sheet