A new feature targeted for Java 12 includes enhancements to the switch statement so it can be used an expression:
For complex expressions, code blocks can be specified:
To learn about this proposed new feature and other enhancements to switch, see JEP 325: Switch Expressions
It may still be an experimental feature, which means it needs to be enabled at both compile and run time. But yes, project Amber is coming up with a lot of interesting stuff.
For those wondering why Ron's first example doesn't need a default clause - that's because the compiler can tell that all enum constants are present in the switch (there will be an exception if the enum has extra constants added without recompiling this class).
One other enhancement from Amber I'm looking forward to is JEP 305. Basically this means you can combine instanceof and assignment into one:
Unfortunately, JEP 326 (raw string literals) has been dropped from Java 12, because of the ambiguity of what `` could mean - an empty string literal, or the start of a string literal. I was quite disappointed by that decision...