Join our book community on Discord
This chapter includes 18 problems meant to cover in detail the Java records introduced in JDK 16 (JEP 395), and record patterns introduced as a preview feature in JDK 19 (JEP 405) and as a second preview feature in JDK 20 (JEP 432).We start by defining a simple Java record. We continue by analyzing record's internals, what it can and cannot contain, how to use records in streams, how they improve serialization, and so on. We are also interested in how we can use records in Spring Boot applications, including JPA and jOOQ technologies.Next, we focus on record patterns for instanceof
, and switch
. We will talk about nested record patterns, guarded record patterns, handling null
values in record patterns, and so on.At the end of this chapter, you'll master Java records. This is great because records are a must-have for any Java developer who wants to adopt the coolest Java features.