Skip to content

core-java

45 Posts

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.

How to Implement the Observer Pattern in Java (Java 21)

Build a stock-alert system with the observer pattern in Java 21: a thread-safe subject, lambda listeners, safe unsubscribe, and 16 checks that prove it works.