3 Java 17

 

This chapter covers the new features that have been added to the Java language and platform since the release of Java 11, up to and including Java 17.

[Note]  Note

To understand the changes in the Java release methodology since Java 8 it may be a good idea to review the discussion in Chapter 1 or Appendix A.

As well as the major, user-visible language upgrades, Java 17 contains many internal improvements (especially performance upgrades). However, for the developer, the major features that we expect will change the way that you write Java are:

  • Text Blocks
  • Switch Expressions
  • Records
  • Sealed Types

Let’s get started by meeting the first of them - Text Blocks.

3.1 Text Blocks

Since the very first version, Java 1.0, developers have been complaining about Java’s strings.

Compared to other programming languages, such as Groovy or Scala or Kotlin, Java’s strings have sometimes seemed a little primitive.

Java has historically provided only one type of string - the straightforward, double-quoted string in which certain characters (notably " and \) must be escaped in order to be used safely. These have, under a surprisingly wide array of circumstances, led to the need to produce convoluted escaped strings even for very common programming situations.

3.2 Switch expressions

3.3 Records

3.3.1 Nominal Typing

3.3.2 Compact Record Constructors

3.4 Sealed types

3.5 New form of instanceof

3.6 Pattern Matching & Preview Features

3.7 Summary

sitemap