Java 17 – the cool new features introduced since Java 11

Master important Java features: Sealed Classes; Records; switch expressions and pattern matching; Text blocks. [2023]

Java has three major LTS (Long Term Support) releases – Java 8, Java 11 and Java 17.

What you’ll learn

  • Sealed classes: customize an inheritance hierarchy using sealed classes and interfaces..
  • Records: save yourself time and effort by utilizing records for data-centric classes..
  • Switch expressions: understand how they work and how to use the ‘yield’ keyword..
  • Pattern matching: for both ‘switch’ and ‘instanceof’..
  • Text blocks: their advantages and how to code them..
  • Preview features: understand what they are and how to enable them in IntelliJ..

Course Content

  • Introduction –> 1 lecture • 1min.
  • Sealed Classes –> 1 lecture • 6min.
  • Records –> 1 lecture • 19min.
  • switch expressions and pattern matching –> 1 lecture • 14min.
  • Text blocks –> 1 lecture • 14min.
  • Assignment –> 0 lectures • 0min.
  • Additional Content –> 7 lectures • 42min.

Java 17 - the cool new features introduced since Java 11

Requirements

Java has three major LTS (Long Term Support) releases – Java 8, Java 11 and Java 17.

I already have 2 Java courses. One covers Java fundamentals: “Complete Java 8 OCA (1Z0-808) Java Certification Course”. The other builds on that course and covers advanced Java, right up to Java 17: “Java 17, Java 11, Advanced Java 8, (1Z0-829, 1Z0-819, 1Z0-809)”.

This new 2023 course is specific to Java 17 and contains the new topics that have been added since Java 11 i.e. it covers the releases 12, 13, 14, 15, 16 and 17. The topics are listed below:

Sealed classes – find out how to customize/scope your inheritance hierarchy.

Records – save yourself a lot of typing by using records to generate boiler plate code.

switch expressions and pattern matching – understand what switch expressions are and how to use pattern matching for both switch statements and expressions. switch expressions also introduced the yield keyword; understand how to use it. Pattern matching is used by both switch and instanceof. As pattern matching switch is a preview feature in Java 17, how to enable this feature in an IDE is shown.

Text blocks – multi-line text can be tedious and error prone with lots of newlines and escaping of the double quotes. Text blocks help in both scenarios by making the code a lot easier to write and therefore maintain.

Assignment – there is a coding assignment that incorporates all of the topics above.

 

Additional Content equals() and hashCode() methods are explained in detail as Records generates default implementations of these methods. Records are immutable so immutable classes are also explained (along with the much misunderstood call-by-value principle). This leads naturally on to Advanced Encapsulation as mutable instance fields can break encapsulation. In addition, the assignment presents a UML diagram with instructions – for those new to UML there are three videos outlining it.

 

By way of background, I am a PhD-qualified University lecturer since 2002. For over a decade, I have taught Java on a bespoke Masters on behalf of a highly regarded software company.

I have recently co-authored a book called “Java Memory Management: a comprehensive guide to garbage collection and JVM tuning” with Maaike van Putten.

I love teaching and this course has all my experience in explaining advanced concepts of Java. In addition, I have a strong attention to detail which lends itself perfectly to the Oracle Java Certification exams. I am delighted that Enthuware, in their explanations, have linked to my YouTube channel.

 

Get Tutorial