+ 1
Can we use relationlal and conditional operators within case?
2 ответов
+ 6
Unfortunately nope, switch case is used for equality comparison only but it can behave like logical OR in traditional if-else like this:-
https://code.sololearn.com/c71KtCEf8yCQ/?ref=app
+ 1
yes we can use.
we can write a multiple lines block in a case.
e.g
switch (x)
case 1 : {}
case 2 :{}
default :{}
in block {} there can be operators.