Call for feedback -- switch expressions in JDK 12

Alex Buckley alex.buckley at
Wed Apr 17 02:00:16 UTC 2019

An easy way to help move Java forward is to try out new features on real 
code and share your experiences. We're asking for feedback on how you 
use switch expressions, the new language feature in JDK 12:

   int numLetters = switch (day) {
       case MONDAY, FRIDAY, SUNDAY -> 6;
       case TUESDAY                -> 7;
       case THURSDAY, SATURDAY     -> 8;
       case WEDNESDAY              -> 9;

   // Multiple labels per case (also allowed in switch statements)
   // No fallthrough with the -> form (also allowed in switch statements)

Do you find switch expressions useful? Is anything surprising? Did you 
turn any switch statements into switch expressions? Please let us know 
on this list, even if the answer is "Tried it. Works fine."

To enable switch expressions in your environment:
- IntelliJ IDEA 2019.1
- Eclipse 4.11
- Apache NetBeans 11.0
- jshell in JDK 12  run with `--enable-preview`
- javac in JDK 12  run with `--release 12 --enable-preview`


More information about the jdk-dev mailing list