Browse by Topic
Popular
Popular Posts
Latest
Latest Java Posts
Java Record Inheritance: What Works and What Doesn't
java record inheritance: Learn how Java records handle inheritance: why they are final, how they implement interfaces, and when to use sealed hierarchies or composition.
Java Record Implements Interface: Syntax and Use Cases
Learn how Java records can implement interfaces, how generated accessors map to interface methods, and when to use a record instead of a class.
Java Record Immutability: Guarantees and Limitations
Java records guarantee immutability for their own fields, but mutable components need extra care. Learn what the compiler enforces, where records are only shallowly immutable, and how to handle validation, defensive copying, and serialization.
Java Record vs Class: When to Use Each
Java records are concise, shallowly immutable data carriers with component-based equality; classes support mutable state, custom equality, and inheritance. This guide explains the practical differences and when each is the better fit.
Java Record toString: Default Format and Customization
A practical look at Java record toString(): the default output format, how to override it, and how to handle sensitive fields and array components.
Java Record hashCode: Default and Custom
Learn how Java records implement hashCode by default, when overriding it makes sense, and how to write a custom hashCode for record classes.
Java Record equals: How It Works and When to Override
Understand how Java records generate equals() and hashCode() automatically, when to override them, and common pitfalls.
Java Record Accessor: Defaults and Customization
java record accessor: Explains how Java record accessor methods are generated, when to customize them, and how defensive copies protect mutable components.
Java Record Methods: Custom Methods and Overrides
Learn how Java record methods work: auto-generated accessors, custom instance methods, compact constructors, static methods, and interface implementations.
Java Record Fields: Syntax and Behavior
Understand Java record fields: how they are declared, accessed, validated, and restricted, with practical examples and edge cases.