Browse by Topic

Popular

Latest

Latest Java Posts

Diagram of a Java record with components flowing into a canonical constructor, emphasizing validation and field assignment.
Java

Understanding the Java Canonical Constructor

Learn how the canonical constructor works in Java records, including explicit and compact constructors, validation, normalization, and defensive copies.

JavaRecordsConstructorsCompact Constructors
Illustration of a Java record with a compact constructor performing validation.
Java

Java Compact Constructor: Syntax and Use Cases

Learn how Java compact constructors work in records: syntax, validation, normalization, common mistakes, and practical examples.

Java recordscompact constructorJava 16validation
Illustration of a Java record constructor showing a compact constructor validating input before implicit field assignment.
Java

Java Record Constructor: Canonical and Compact Forms

java record constructor: How Java record constructors work: the implicit canonical constructor, compact constructor syntax for validation, secondary constructors, and...

Java recordscompact constructorcanonical constructorJava 16
Java record declaration showing a compact data class with generated methods
Java

Java Record Declaration Explained

Learn how to declare Java records, what the compiler generates, how to add validation, and when records are the right choice for immutable data.

Java recordsimmutable dataJava 16data classes
Java record class concept showing immutable data container with generated methods
Java

Java Record Class: Syntax and Practical Use

Learn to define Java record classes for immutable data: concise syntax, generated constructors and accessors, compact constructors, and practical tradeoffs.

JavaRecordsImmutabilityData Classes
A Java record declaration showing concise syntax for immutable data carriers.
Java

Java Record: Syntax, Usage, and Tradeoffs

Learn how Java records reduce boilerplate for immutable data carriers, including syntax, customization, and when to use them.

JavaRecordsImmutable DataData Carriers
Illustration showing enum constants being transformed into readable display strings with a connecting arrow
Java

Java Enum toString: Override and Use It Correctly

Override toString() in a Java enum to control how enum constants appear in logs and UI, while keeping name() and valueOf() behavior predictable.

javaenumstostringvalueof
A split visual comparing a Java enum declaration with a set of static final constant fields, emphasizing type safety.
Java

Java Enum vs Constants: Choosing the Right Approach

java enum vs constants: Compare Java enums and constants for type safety, maintainability, and runtime behavior to choose the right approach for your codebase.

enumconstantstype-safetyswitch-expressions
Diagram of a Java enum with associated values and methods
Java

Java Enum with Values: Fields, Constructors, and Lookup

Learn to define Java enums with associated values: add fields and constructors, expose methods, and look up constants by code or label.

JavaEnumsObject-Oriented ProgrammingType Safety
Diagram showing Java enum constants implementing an interface with distinct method behaviors.
Java

Java Enum Interface Implementation: Patterns and Pitfalls

Learn how to implement interfaces with Java enums, including constant-specific behavior, strategy usage, and common pitfalls.

Java enumsInterface implementationStrategy patternConstant-specific methods