+ 4
Explain when switch statements is used in Java?
I don't understand what is Switch Statement? When it is used in Java?
3 Answers
+ 3
Thanks
+ 1
using else if:
if (...) {...}
else if (...) {...}
else (...) {...}
using switch:
swich (...) {
case 1:
...;
case 2:
...;
...
}
Switch statements are cleaner than else if statements if you have many choices.
- 2
never