Module 58 Extra
Pattern matching and sealed types
An extra module, not part of the MOOC. Patterns, which test what kind of object you have and take it apart in the same step, and sealed types, whose complete list of subtypes Java knows. instanceof with a pattern variable (Java 16), sealed interfaces and their permitted classes (Java 17), switch on sealed types with type patterns and when guards, and record patterns, nested ones too (Java 21).