Browse by Topic

Popular

Latest

Latest Java Posts

Illustration of Java generics wildcard super showing a collection accepting supertypes of a type parameter.
Java

Java Wildcard Super: Using ? super T Correctly

java wildcard super: Understand the `? super T` wildcard in Java generics, its role in the PECS rule, and how to use it for flexible, type-safe collection methods.

java genericswildcardslower-bounded wildcardPECS
Illustration of a Java generic wildcard with extends showing a read-only container and type safety boundaries
Java

Java Wildcard Extends: Upper Bounded Generics

Understand how `? extends T` works in Java generics: when to use the upper bounded wildcard, its write restrictions, and how it differs from generic methods.

GenericsWildcardsType SafetyPECS
Illustration of a Java wildcard being captured into a concrete type variable inside a helper method, symbolizing generic type safety.
Java

Java Wildcard Capture: Why It Happens and How to Fix It

Java wildcard capture: Learn why the compiler uses wildcard capture, how helper methods capture wildcard types, and when this pattern is necessary in Java code.

GenericsWildcardsType InferenceCompilation
Diagram showing a question mark wildcard with extends and super bounds over generic type containers
Java

Java Generics Wildcards Explained

java generics wildcards: Learn how Java generics wildcards work, including unbounded, upper-bounded, and lower-bounded wildcards, with practical examples and common pi...

java genericswildcardstype safetygeneric methods
A diagram showing a sealed interface with three permitted record subclasses and a switch expression that covers all cases, illustrating exhaustive pattern matching.
Java

Java Sealed Class Pattern Matching Explained

Learn how sealed classes and pattern matching in Java combine to produce exhaustive, compile-time-checked switch expressions and safer type hierarchies.

sealed classespattern matchingswitch expressionsrecords
Illustration of a sealed class hierarchy where one branch is marked non-sealed and opens to unknown subclasses.
Java

Java Non Sealed Class: Breaking a Sealed Hierarchy

Understand the java non sealed class modifier: its syntax, how it differs from sealed and final, and when to open a sealed hierarchy for extension.

sealed classesJava 17class modifierstype hierarchy
An illustration of a sealed class hierarchy with a permits clause restricting allowed subclasses.
Java

Java permits clause: Sealing Class Hierarchies

Learn how the Java permits clause restricts subclass hierarchies in sealed classes and interfaces, including syntax, constraints, reflection, and maintenance.

sealed classesjava 17type hierarchyinheritance
Side-by-side comparison of Java record and immutable class structures highlighting equality and data carrier design.
Java

Java Record vs Immutable Class: Choosing the Right Data Carrier

Compare Java records and immutable classes for data modeling: syntax, equality, serialization, and when each approach fits better.

Java recordsimmutable classesdata carriersvalue objects
A visual comparison between a Java record and Lombok's @Data annotation, showing immutable data carrier versus mutable class with generated methods.
Java

Java Record vs Lombok Data: Choosing the Right Approach

Compare Java records and Lombok @Data for creating data classes. Learn syntax, immutability, customization, compatibility, and when to use each approach.

Java RecordsLombokImmutabilityData Classes
A visual representation of a Java record being destructured into its components via a pattern matching arrow.
Java

Java Record Pattern: Destructuring and Matching

Learn how Java record patterns destructure records in instanceof and switch, including nested patterns and guards.

JavaRecord PatternsPattern MatchingJava 21