The Java Collections Framework
A small set of interfaces describes how groups of objects behave, and many implementations trade memory, ordering and speed differently.
List, Set, Map, Queue and the collections framework.
9 notes
A small set of interfaces describes how groups of objects behave, and many implementations trade memory, ordering and speed differently.
A List keeps insertion order and allows duplicates. ArrayList is the default; LinkedList wins only at the ends.
A Set stores unique elements. The three implementations differ in ordering and in what uniqueness is based on.
A Map stores key to value pairs with unique keys, and it is the collection you will reach for most often.
Buckets, hashing, collisions and resizing. Understanding the mechanism explains the performance and every rule about keys.
A Queue processes elements in an order it decides. A Deque works at both ends, and it is the right way to build a stack in Java.
An Iterator walks a collection one element at a time, and it is the only safe way to remove during a traversal.
Comparable gives a class one natural order. Comparator supplies any number of orders from outside, without touching the class.
The helper methods that save writing loops, and a practical way to pick the right collection every time.