Java 22 has many language features that Java 8 could only dream of - let's see what (dirty) tricks we can play with them: We'll see how to pattern-match `Optional`, how to expand a sealed type hierarchy, why nested switches may (?) be good for documentation, and how a reverse `instanceof` check is both elegant and questionable. We'll also go into text block line endings and filtering streamy by type.
~~~ Links ~~~
* Java 17 to 20 Pattern Matching Full tutorial with Records, Instanceof and Switch: https://www.youtube.com/watch?v=aKaw9W789wU
* How can you use flatMap to filter a stream? https://www.youtube.com/shorts/iEWHbGuzLlo
* Where to use Optional: https://www.youtube.com/watch?v=9R8G8Ehzn8o
* Text Blocks: https://www.youtube.com/watch?v=NDaA9MrTLBM
~~~ Chapters ~~~
0:00 Intro
1:13 Expandable Sealed Types
3:00 Nesting Switches
5:22 Reverse Instanceof
6:36 Filter A Stream By Type
7:38 JDK 22 Launch Stream
https://dev.java/community/java-22-launch/
8:11 Switching Over Optional
9:53 Text Block Line Endings
12:04 Good or Dirty?
12:58 Outro
Tags: #Java, #Java22, #OpenJDK