Browse by Topic

Popular

Latest

Latest Java Posts

Diagram showing a record being destructured into its components using a pattern matching arrow.
Java

Java Record Patterns: Destructuring and Matching

Learn how Java record patterns destructure records in pattern matching, including nested patterns, switch integration, and common pitfalls.

record patternspattern matchingJava 21switch expressions
Illustration of Java guarded patterns showing a switch statement with a when clause filtering values.
Java

Java Guarded Patterns: Matching with Conditions

Use the when clause in Java switch pattern matching to add conditions to type and record patterns. Includes syntax, examples, and common pitfalls.

Pattern MatchingSwitch ExpressionsJava 21Records
Illustration of Java type patterns showing a variable being matched against multiple types in a switch statement.
Java

Java Type Patterns: instanceof and switch

Learn how Java type patterns simplify instanceof checks and switch statements, with practical examples of pattern variables, flow scoping, guarded patterns, and record patterns.

pattern matchinginstanceofswitch expressionstype patterns
Illustration of a Java switch statement with type patterns, showing a value being matched against multiple type cases.
Java

Java Pattern Matching Switch

java pattern matching switch: Learn how to use pattern matching for switch in Java: syntax, guarded patterns, exhaustiveness, null handling, and practical migration tips.

JavaPattern MatchingSwitch ExpressionsType Patterns
Illustration of Java pattern variable binding a matched object to a typed variable in an instanceof check.
Java

Java Pattern Variables: Cleaner Type Checks Without Casts

java pattern variable: Understand Java pattern variables: how they simplify instanceof checks and switch patterns, their scope rules, and version requirements.

pattern matchinginstanceofswitch expressionsJava 21
Illustration comparing Java var keyword with Object type, showing type inference preserving specific type versus Object losing type details.
Java

Java var vs Object: Type Inference vs Explicit Reference

java var vs object: Understand the difference between Java's var and Object declarations, how type inference works, and when to use each for maintainable code.

Javavar keywordtype inferenceObject type
Illustration of the Java var keyword interacting with a lambda expression, showing the type inference boundary.
Java

Using var with Lambda Expressions in Java

How var interacts with lambda expressions in Java: why var cannot hold a lambda, how var works in lambda parameters since Java 11, and the all-or-nothing rule.

JavaLambda Expressionsvar KeywordType Inference
Illustration of Java var keyword inferring generic types with type inference arrows.
Java

Java var with Generics: Type Inference Explained

Understand how Java's var keyword infers generic types, including the diamond operator, generic method calls, anonymous classes, and common pitfalls.

var keywordgenericstype inferenceJava 10
Java code editor showing a var declaration with an arrow pointing to the inferred type annotation
Java

Java Local Variable Type Inference: Using var Effectively

java local variable type inference: Learn how Java's var keyword works, where it can be used, and how it affects readability, maintainability, and runtime behavior in...

Javavar keywordtype inferenceJava 10
Diagram comparing immutable and unmodifiable Java collections, showing how unmodifiable views reference a mutable backing collection.
Java

Java Immutable vs Unmodifiable Collection: Key Differences

Understand the difference between immutable and unmodifiable collections in Java, including behavior, performance, and when to use each.

immutable collectionsunmodifiable collectionsJava collectionsList.of