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.
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.
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.
ConcurrentModificationException usually has nothing to do with threads. Here is exactly what modCount does, why it fires, and the four fixes that actually work.
IllegalArgumentException: Comparison method violates its general contract! comes from TimSort, not your code. Here is why it fires, and how to fix the comparator.
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.
Collectors.toMap throws IllegalStateException: Duplicate key when two elements map to the same key. Exact causes, JDK 8-25 message differences, and the fixes.
How to remove duplicates from a list in Java and keep order: LinkedHashSet, distinct(), removeIf and by-key dedupe, on a parcel-scan feed with 21 checks.
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.
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.