Another cool addition of JEP 406 is its support for handling `null` in switches. You know how you need to do `null`-check before `switch` if you can't be sure and want to prevent an NPE? That's a future thing of the past! 🧵 1/5
Another cool addition of JEP 406 is its support for handling `null` in switches. You know how you need to do `null`-check before `switch` if you can't be sure and want to prevent an NPE? That's a future thing of the past! 🧵 1/5 https://t.co/kVy3YG4bvv
From #Java17 on, a switch's case label can include `null`, e.g. `case null -> ...`. If the switched-over variable is `null` and such a label exists, the corresponding branch gets executed. If it doesn't exist, an NPE is thrown as before. 2/5