what are advantages of switch case over if ()? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

what are advantages of switch case over if ()?

7th Oct 2017, 4:40 PM
Harsh Tirkey
Harsh Tirkey - avatar
2 Answers
+ 17
As a complement for dear Jamie's explanation, you'd take a look at this link for further information. [https://stackoverflow.com/questions/1028437/why-switch-case-and-not-if-else-if]
7th Oct 2017, 5:02 PM
Babak
Babak - avatar
+ 7
switch case is much faster to execute, coz compiler directly jumps to the case while in a if-else it has check each statement, if its true or not.
7th Oct 2017, 5:25 PM
Meharban Singh
Meharban Singh - avatar