I'm mostly just curious, is using if/else and a switch statement just a matter of personal preference, or do they actually work differently? Is one more efficient than the other? If they are, why exactly?
Asked
Active
Viewed 624 times
1
-
See also the second answer of http://stackoverflow.com/questions/2086529/what-is-the-relative-performance-difference-of-if-else-versus-switch-statement-i – assylias Feb 28 '13 at 23:15
1 Answers
2
if your case more than four, switch-case statement is more effiecient. your case directly jumped. on the other hand if you use if-else statement all cases compared until your cases is crossed.

Ahmet Karakaya
- 9,899
- 23
- 86
- 141