This repository contains several examples for "Pattern Matching for switch", a feature described in JEP 441 and released in Java 21.
IntelliJ IDEA supports Java 21 as of version 2023.2.2. As long as this version is not yet released, you can install the release candidate via the JetBrains Toolbox App by going into the IntelliJ IDEA settings and activating the "Early Access Program".
If your favorite IDE does not yet support the new Java version,
you can run any file via the java
command, for example:
cd src/main/java/eu/happycoders/java21/patternmatching
java Example05_SwitchWithTypePattern.java
You can download Java 21 from here: https://jdk.java.net/21/
To install multiple Java versions on Linux or macOS, I recommend using SDKMAN!
To install multiple Java versions on Windows, have a look at this tutorial: How to Change Java Versions in Windows
You might also find these GitHub repositories interesting:
Virtual Threads:
- https://github.com/SvenWoltmann/virtual-threads
- https://github.com/SvenWoltmann/virtual-threads-quarkus
- https://github.com/SvenWoltmann/virtual-threads-spring
Structured Concurrency:
Scoped Values: