0

What expression can we put within the parenthesis of a switch statement?like we can use any expression? Switch(any expression)

25th Jun 2017, 5:17 PM
Raktim Mukherjee
Raktim Mukherjee - avatar
5 Antworten
+ 2
You cannot use floats or doubles in the switch statement. I believe also a boolean is impossible for switch. long might be to. It's really meant for int (short/byte) or char/string.
25th Jun 2017, 5:37 PM
Rrestoring faith
Rrestoring faith - avatar
+ 1
Yep, any expression is possible!
25th Jun 2017, 5:32 PM
Maart
Maart - avatar
+ 1
It may not be, but if you want a useful switch case, it should be. A switch case is just like an if-statement with multiple else-if-statements, so you can put anything after case that you could put in an if-statement too
25th Jun 2017, 5:37 PM
Maart
Maart - avatar
+ 1
thank u very much both of u :)
25th Jun 2017, 5:45 PM
Raktim Mukherjee
Raktim Mukherjee - avatar
0
the expression may not be related to the input string then?
25th Jun 2017, 5:34 PM
Raktim Mukherjee
Raktim Mukherjee - avatar