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
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.
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.