Browse by Topic

Popular

Latest

Latest Java Posts

Diagram showing a Java class containing a nested inner class with an arrow indicating access to the outer class instance.
Java

Java Inner Class: Syntax, Types, and When to Use Them

Understand Java inner and nested classes—member, local, anonymous, and static nested—with syntax examples, access rules, and practical guidance.

inner classesnested classesanonymous classesJava syntax
Diagram showing four types of Java nested classes and their relationship to the enclosing class instance.
Java

Java Nested Class: Types, Syntax, and Memory Behavior

An overview of Java's four nested class types: static nested, inner, local, and anonymous. Covers syntax, access rules, memory behavior, and when to use each kind.

JavaNested ClassesInner ClassesAnonymous Classes
A sealed interface with a finite set of permitted implementations, shown as a closed box with labeled compartments.
Java

Java Sealed Interface Implementation

Learn how to implement sealed interfaces in Java: the permits clause, restrictions, records, exhaustive pattern matching, and API design trade-offs.

sealed interfacesJava 17type hierarchypattern matching
Diagram of a sealed class hierarchy with permitted subtypes and a lock icon representing restricted inheritance.
Java

Java Sealed Class Inheritance: Syntax and Rules

Learn how Java sealed class inheritance restricts direct subtypes, which modifiers permitted subtypes need, and how sealed hierarchies support exhaustive pattern matching.

sealed classesJava 17type hierarchypattern matching
Diagram comparing sealed and final class inheritance in Java
Java

Java Sealed vs Final: Key Differences

Sealed and final classes both control inheritance in Java, but they solve different problems. See the syntax, behavior, and when to use each.

sealed classesfinal classesJava inheritanceJava 17
Diagram showing a sealed class hierarchy with one non-sealed branch open to subclasses
Java

Java non-sealed Keyword: Extending Sealed Types

The Java non-sealed keyword reopens a sealed type hierarchy to arbitrary subclasses. Learn how it works, when to use it, and how it affects subtype extensibility.

Javasealed classesnon-sealedinheritance
Illustration of a sealed class with a permits clause restricting subclasses to a fixed set.
Java

Understanding the Java Permits Keyword in Sealed Classes

The Java `permits` keyword defines the allowed subclasses in sealed classes and interfaces. This guide covers syntax, constraints, and runtime behavior.

sealed classespermits clauseJava 17pattern matching
Illustration of a sealed envelope with a Java logo, representing a sealed interface restricting its permitted implementations.
Java

Using Java Sealed Interfaces for Exhaustive Pattern Matching

Java sealed interfaces restrict implementations and enable compiler-checked exhaustive switch expressions. See how to declare them, compare them with sealed classes, and understand when to use them.

sealed interfacespattern matchingswitch expressionstype hierarchy
Diagram showing a sealed class with a limited set of permitted subclasses, illustrating restricted inheritance in Java.
Java

Java Sealed Keyword: Restricting Inheritance

Learn how Java's sealed keyword restricts class hierarchies, enables exhaustive switching, and improves maintainability in Java 17+.

JavaSealed ClassesInheritancePattern Matching
Illustration of a sealed class hierarchy with permitted subclasses and a lock symbol representing restricted inheritance.
Java

Using Java Sealed Classes to Control Inheritance

Learn how Java sealed classes restrict inheritance, enable exhaustive pattern matching, and improve API design with practical examples.

sealed classesJava 17inheritance controlpattern matching