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.
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.
Replace nested null checks with Optional in a support-ticket service, then see which orElse, get and field habits bite. Java 21 code you can run today.
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.
Implement the command pattern in Java 21 on a to-do list with undo, redo and macro commands, backed by 18 checks and the traps that quietly break undo.
Learn how to use Java's CompletableFuture for async programming — with real payment pipeline examples covering supplyAsync, thenCompose, thenCombine, error handling, and custom thread pools. Covers Java 8, 9, and 21.
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.
Build a library loan desk in plain Java 21: an enum with fields, a lookup by code, per-constant behaviour, and a small state machine, all checked by 36 tests.
Build a folder watcher in Java 21 with WatchService. It copes with half-written files, duplicate events and overflow, and ships with 23 passing checks.
Build a small CSV reader and writer in plain Java 21 that handles quoted commas, line breaks and BOMs, then use it on a currency rates file. No dependencies.
Loop over a Java Map the right way: entrySet, forEach, iterator removal, sorted output and the exceptions to expect, built on a small currency-rates feed.