Loading topic
try, catch, and try-with-resources work, and you should be comfortable with lambda expressions. You should also have seen records and basic instanceof and switch usage.7 min readcatch blocks, lambdas and records. You do not need to know patterns in detail yet. They come later.8 min readtry/catch blocks. It also assumes you know what a lambda expression is. All code targets Java 22 or later. In Java 22 the feature is final (JEP 456), so no preview flag is needed.7 min readfor and enhanced for loops, and methods. You should know that try (...) closes resources automatically when the block ends. You should also know that var lets the compiler infer a local variable's type.7 min readcatch block and the parameters of a lambda expression. Since Java 22 you can write _ in both. It assumes you know these things:6 min readType _ form of a pattern: a type test that does not give the matched value a name. It assumes you know records, instanceof with type patterns, switch with case labels, and sealed interfaces. It also assumes you have seen unnamed local variables (var _) in earlier ch6 min readinstanceof with type patterns, switch with patterns, and the basic rule that _ can name a variable you never read. You also need nested record patterns, such as Line(Point(int x, int y), Point end). The chapter uses Java 22 or later, where unnamed patte6 min readswitch expressions, sealed interfaces, records, and the unnamed variable _ from the earlier chapters. You should also be comfortable with type patterns (Circle c) and record patterns (Line(Point a, Point b)).7 min read_ from the earlier chapters: unnamed locals, loop variables, catch parameters, lambda parameters, Type _ pattern variables, and the unnamed pattern _ in record patterns. It also assumes you know sealed types, records, and switch patte5 min read_ as an unnamed variable, why older code can't use it, and how to move existing code over without changing its behavior. It assumes you have read the earlier chapters on unnamed variables, unnamed patterns, and the restrictions on where _ is allowed7 min read