With switch
becoming an expression, it can have a return value (instead of having to assign or return results) and with a lambda-like syntax that doesn't fall-through (no more break
🎉) and exhaustiveness checks (less default
) it is much more readable.
So much to talk about!
First Contact with Switch Expressions in Java 12
//
With Java 12, switch
is no longer just a statement, but becomes an expression. Let's take a look!