Skip to content

modern-java

6 Posts

How to Use Sealed Classes and Interfaces in Java 21

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.

How to Use var in Java Without Hurting Readability

Learn how to use var in Java 10+ on a parcel tracker: where it helps, the diamond and ternary traps, 12 compiler errors forced on purpose, and 11 checks.