Just trying to figure out how to use many multiple cases for a Java switch statement. Here\'s an example of what I\'m trying to do:
switch (variable)
{
c
From the last java-12 release multiple constants in the same case label is available in preview language feature
It is available in a JDK feature release to provoke developer feedback based on real world use; this may lead to it becoming permanent in a future Java SE Platform.
It looks like:
switch(variable) {
case 1 -> doSomething();
case 2, 3, 4 -> doSomethingElse();
};
See more JEP 325: Switch Expressions (Preview)