sebastiandaschner blog

What You Need to Know About Java Records

#java wednesday, november 16, 2022

In this video I’ll explain what you need to know about Java Records (JEP 395), what they are good for, how to use them, and why you should care:





  • extend java.lang.Record

  • are implicitly final (can’t be abstract)

  • can’t declare fields other than in the header

  • can’t declare native methods

  • can have static methods, fields, initializers

  • can implement interfaces

  • can have an nested type, including nested record classes


Records will have:

  • private final fields for each header component

  • public accessor methods

  • a canonical constructor (same signature as header)

  • equals(), hashCode()

  • toString()

Also make sure to check out JEP 395: Records


Found the post useful? Subscribe to my newsletter for more free content, tips and tricks on IT & Java: