Call for feedback -- switch expressions in JDK 12

Alex Buckley alex.buckley at
Sat Mar 30 00:19:19 UTC 2019

Hi everyone,

People often ask how they can contribute to the Java development 
process. One of the easiest ways is to try out new features _on real 
code_ and share your experiences. We would love to hear how you're using 
the new language feature available on a preview basis in JDK 12 -- 
switch expressions.

Switch expressions make it easy to express multi-way conditionals in a 
compact, readable manner. Unlike switch statements, switch expressions 
don't fall through from one case to the next. Also, switch expressions 
on enums don't require a default if the cases are exhaustive. Also, 
multiple labels per case. See for more.

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

What works? What doesn't work? What was surprising? (Asking about use of 
the language feature, not setup of the IDE.)

Please respond here, or on the amber-dev list. Thank you in advance!


More information about the jdk-dev mailing list