Loading topic
_ was an ordinary name, then a compile error, and then the marker for "unused" in Java 22.3 min readfor loop, try-with-resources, and basic exceptions. It uses Java 22 or later, where unnamed variables (JEP 456) are a standard feature.3 min readtry/catch, multi-catch, lambda expressions, and the functional interfaces Function and BiConsumer. It also assumes you have seen the basic form of an unnamed variable, _. The code runs on Java 22 or later. On Java 21, add --enable-preview --source 21.2 min readinstanceof, and switch. It reviews two Java 21 features that the rest of this tutorial builds on: type patterns and record patterns. Every example here binds a name for every value it matches. That requirement is what unnamed patterns relax lat3 min readinstanceof, and switch. It also assumes you have seen type patterns and record patterns. You need Java 22 or later. In Java 21 the feature is a preview and needs --enable-preview.3 min readinstanceof patterns, and the type and record patterns from the previous chapter. It also assumes you know what an unnamed pattern variable (Type _) is. The code needs Java 22 or later.3 min readswitch expressions with type patterns. It also assumes you have met unnamed pattern variables (Type _) and the unnamed pattern (_) from the previous chapters. You need Java 22 or later.2 min read_ from earlier chapters: unnamed locals, catch and lambda parameters, unnamed pattern variables (Type _), and the unnamed pattern (_). Here you learn where the compiler rejects _. These are Java 22 rules (JEP 456).2 min read_ before it became a feature, and how to move existing code over.3 min read_: unnamed local variables, loop variables, catch and lambda parameters, unnamed pattern variables (Type _), and the unnamed pattern (_) inside record patterns. It also assumes you can read switch with record patterns. The question here is n3 min read