+ 1
Compare the if statement and switch statment
4 Answers
+ 10
The if statement tests a condition.
The switch statement tests a variable for equality against different values.
+ 8
if is slower than switch as for switch-case, compiler directly pass to the required value.In if, it check for each if part and verifies if it is true of false.
switch cannot handle difficult expressions .Example đ¤, case 'x+7' is not valid, if can.
+ 3
How?
+ 1
In terms of code