The switch statement is one of the more syntactically complicated expressions in Java. The expression in the switch statement must be of type char, byte, short, or int. It cannot be boolean, float, double, or String.
Can we pass boolean in switch case?
This is another reason, why switch-case is not for boolean type. There is no default case. According to the JLS section 14.11: for a switch ( Expression ) SwitchBlock : Expression can only be char, byte, short, int, Character, Byte, Short, Integer, String, or an enum type other wise a compile-time error occurs.
Can we use boolean in switch case in C?
Switch Statement Structure
A switch statement takes a single value, then compares it to a bunch of other values using a boolean expression. When one of these boolean expressions is true then a specific piece of code will execute. ... These case statements are essentially the right side of a boolean expression for equality.