[switch] Further unification on switch

Brian Goetz brian.goetz at oracle.com
Thu Apr 19 22:27:06 UTC 2018

> Can a single-statement case have a variable declaration as that 
> statement, and what would be its scope?

No, a local variable declaration is a BlockStatement (JLS 14.2), not a 
Statement (JLS 14.5).  So you could say:

     case FOO -> println(3);


     case FOO -> {
         int x = 4;

Of course, you don't have to ask about the scope of x.

More information about the amber-spec-observers mailing list