The second option is completely fine. I’m not sure why a responder said it was not possible. This is fine, and I do this all the time:
switch (variable)
{
case 5:
case 6:
etc.
case 100:
doSomething();
break;
}
More Related Contents:
- Java Illegal start type ) expected [closed]
- how to define a constructor outside class in java?
- What is the Java ?: operator called and what does it do?
- Is there a difference between x++ and ++x in java?
- Difference between >>> and >>
- What is the relative performance difference of if/else versus switch statement in Java?
- Why is “extends T” allowed but not “implements T”?
- Java: Syntax and meaning behind “[B@1ef9157”? Binary/Address?
- Switch without break
- Is there a difference between single and double quotes in Java?
- Java for loop syntax: “for (T obj : objects)”
- WITH statement in Java
- Variable’s scope in a switch case [duplicate]
- Is it possible to make anonymous inner classes in Java static?
- Java “?” Operator for checking null – What is it? (Not Ternary!)
- Using two values for one switch case statement
- How to ensure completeness in an enum switch at compile time?
- Why does Java switch on contiguous ints appear to run faster with added cases?
- Any Java libraries out there that validate SQL syntax? [closed]
- Labeled Statement block in Java?
- Why is this Java code in curly braces ({}) outside of a method?
- XML syntax validation in Java [closed]
- Kotlin ‘when’ statement vs Java ‘switch’
- The difference between += and =+
- What’s the difference between this and Activity.this
- What are switch expressions and how are they different from switch statements?
- Why can’t your switch statement data type be long, Java?
- Converting decimal to binary in Java
- What do < and > mean such as implements Comparable?
- Maximum number of enum elements in Java