Skip to content
Advertisement

Java switch statement multiple cases

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:

JavaScript

versus having to do:

JavaScript

Any ideas if this possible, or what a good alternative is?

Advertisement

Answer

Sadly, it’s not possible in Java. You’ll have to resort to using if-else statements.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement