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.
In financial systems built on Apache Kafka and Flink, background scheduling is everywhere: checking consumer lag every 30 seconds, expiring distributed locks after a payment SLA window, scheduledExecutorService is production-grade answer to all of this.
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.
Build a small expense tracker with Java 21 records: compact constructors, validation, defensive copies, with-ers and the array trap, all compiled and run.
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 currency-rate feed in Java 21 where the compiler flags every switch you forgot to update. Sealed interfaces, records and sealed classes, step by step.
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.