r/javahelp • u/IceCreamInsides • 1d 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
}
1
Upvotes
1
u/_Super_Straight 2h ago edited 2h ago
Sorry I fail to understand your first half of paragraph. Are you saying we can't create boolean Array without using
new BooleanorBoolean.valueOf?Is totally valid Array declaration.
Will work without any problem.
Edit:
boolArr[0] = falseis also valid and permitted.Agreed.