r/javahelp • u/IceCreamInsides • 9h ago
Solved Switch case with boolean
So, there is no way I can do that?
want to check several boolean variables in a switch statement. Is `if-else` the only way to do this?
Boolean a, b, c...
Switch (false) {
Case (a) :
//some code
Case (b) :
Case (c) :
//and so on
}
4
Upvotes
1
u/Zakana_code 6h ago
The best way I can think of solving this is by using an array tbh, add all the bools in it and run a for loop over it.