+ 2
What is difference between if else and switch case in java.
5 Antworten
0
Maninder Singh in a switch statement you can only check one variable for certain cases. in if else statements you can check for multiple conditions for example. hope that helps.
+ 2
MMJ It is not always faster. I did some code on an arduino and with 16 cases, the ifs were faster.
0
I think switch searches the result by a hash, so for a lot of cases it is faster that if/else
0
Switch can be used as if else and vice versa is also true. The performance may very. In small code the performance may not very that much but in large codes, switch is better.
0
my java error