Fastutil
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.
A responsive HTML conversion of the supplied one-page Java Collections Cheat Sheet, preserving its collection comparison, performance, and notable-library information.
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.
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.
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.
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.
| Collection class | Thread-safe alternative | Individual elements | Key-value pairs | Duplicate element support | Primitive support | FIFO | Sorted | LIFO | Performant contains check | By key | By value | By index |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| HashMap | ConcurrentHashMap | ✓ | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ |
| HashBiMap (Guava) | Maps.synchronizedBiMap | ✗ | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✓ | ✗ |
| ArrayListMultimap (Guava) | Maps.synchronizedMultiMap | ✗ | ✓ | ✓ | ✗ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ |
| LinkedHashMap | Collections.synchronizedMap | ✗ | ✓ | ✗ | ✗ | ✓ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ |
| TreeMap | ConcurrentSkipListMap | ✗ | ✓ | ✗ | ✗ | ✗ | ✓ | ✗ | ✓ | ✓ | ✗ | ✗ |
| Int2IntMap (Fastutil) | — | ✗ | ✓ | ✗ | ✓ | ✗ | ✗ | ✗ | ✓ | ✓ | ✗ | ✗ |
| ArrayList | CopyOnWriteArrayList | ✓ | ✗ | ✗ | ✗ | ✓ | ✗ | ✓ | ✗ | ✗ | ✗ | ✓ |
| HashSet | Collections.newSetFromMap | ✓ | ✗ | ✗ | ✗ | ✗ | ✗ | ✓ | ✗ | ✗ | ✓ | ✗ |
| IntArrayList (Fastutil) | — | ✓ | ✗ | ✓ | ✓ | ✓ | ✗ | ✓ | ✗ | ✗ | ✗ | ✓ |
| PriorityQueue | PriorityBlockingQueue | ✓ | ✗ | ✓ | ✗ | ✗ | ✓** | ✗ | ✗ | ✗ | ✗ | ✗ |
| ArrayDeque | ArrayBlockingQueue | ✓ | ✗ | ✓ | ✗ | ✓** | ✗ | ✓** | ✗ | ✗ | ✗ | ✗ |
offer() / poll(). fileciteturn2file0L81-L81| Collection class | Random access by index / key | Search / Contains | Insert |
|---|---|---|---|
ArrayList | O(1) | O(n) | O(n) |
HashSet | O(1) | O(1) | O(1) |
HashMap | O(1) | O(1) | O(1) |
TreeMap | O(log(n)) | O(log(n)) | O(log(n)) |
The original one-page visual is preserved below so the comparison matrix and original layout remain available alongside the converted HTML version.