Skip to content

java-collections

14 Posts

How to Implement Comparable and Comparator in Java 21

Sort a warehouse stock list by SKU, name, price and expiry date with Comparable and Comparator on Java 21, then prove the order with 28 runnable checks.

How to Use PriorityQueue and TreeMap in Java (Java 21)

Build a support-ticket desk in Java 21: a PriorityQueue that hands out the next ticket, a TreeMap that answers SLA deadline questions, and seven forced traps.

How to Collect Stream Results in Java: Collectors Guide

Build a URL-shortener click report that uses groupingBy, partitioningBy, toMap, teeing and a custom Collector on Java 21, with 21 checks and the errors I hit.

How to Use ConcurrentHashMap in Java: A Stock Service

Build a thread-safe stock service in Java 21 with ConcurrentHashMap: merge, compute, computeIfAbsent, and the get-then-put trap that lost 300,000 updates.

How to Filter and Transform a List with Java Streams

Turn a for loop into a Java streams pipeline that filters and transforms a list. Build a gradebook in Java 21, trip every classic mistake, and check it all.