Java Collections and Data APIs
Lists, sets, maps, queues, streams, Optional, dates, regex and serialisation. The Collections Framework, ArrayList/LinkedList, HashMap and streams/lambdas have their own pages earlier in this subject.
This is an overview — pick a sub-topic below.
Sub-topics (16)
List Interface
An ordered collection allowing duplicates and index access.
Set Interface
A collection without duplicates.
HashSet
A hash-table set with $O(1)$ average operations and no ordering.
TreeSet
A sorted set (red-black tree) with $O(\log n)$ operations and navigation methods.
Map Interface
Key → value associations.
TreeMap
A sorted map with $O(\log n)$ operations and navigation (`floorKey`, `ceilingEntry`, `subMap`).
LinkedHashMap
A hash map that remembers insertion (or access) order.
Queue Interface
FIFO operations: `offer`, `poll`, `peek`.
Deque Interface
Double-ended queue — also Java's recommended stack.
PriorityQueue
A binary heap: `poll()` returns the smallest element (or by a Comparator).
Iterator
Walk through a collection and safely remove elements while iterating.
Method References
Shorthand for lambdas that call an existing method.
Optional
A container that may hold a value — makes "no result" explicit instead of returning null.
Date and Time API
`java.time`: immutable `LocalDate`, `LocalDateTime`, `Instant`, `ZonedDateTime`, `Duration`, `Period`.
Regular Expressions in Java
`Pattern` and `Matcher` from `java.util.regex`.
Serialization
Convert objects to bytes or text and back.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.