which one is better, switch case or if else? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

which one is better, switch case or if else?

in selection condition which one is better, switch case or if else?

10th Feb 2017, 4:55 PM
Deni Supriadi
Deni Supriadi - avatar
4 Answers
+ 6
that really depends on the values and the conditions.
10th Feb 2017, 5:05 PM
Mario L.
Mario L. - avatar
+ 5
switch case because much more faster if else and if else eat a ram like a tiger :)
11th Feb 2017, 12:26 AM
Samet Aydın
Samet Aydın - avatar
+ 3
switch is used as substitution to if statement with many branches, for branching enum options, for multiple ranges and for special switch(true) design.
10th Feb 2017, 5:08 PM
Zilvinas Steckevicius
Zilvinas Steckevicius - avatar
+ 1
switch case is faster than the if else ladder. If you have multiple options to choose from use switch statement.
10th Feb 2017, 5:36 PM
Varun Moghe
Varun Moghe - avatar