+ 3

Where should i use switch? because i can accomplish my task with if elses.

is there any disadvantage of using switch instead of if elses, in java?

18th Jan 2018, 4:37 PM
sal sal
sal sal - avatar
3 Answers
+ 3
I find switch easier to read and much faster to write, not sure how it affects performance.
18th Jan 2018, 4:55 PM
Jacob Pembleton
Jacob Pembleton - avatar
+ 3
in if else we have to check every condition but in switch once the condition is checked it searches for the matching case
14th Feb 2018, 8:09 AM
haritha polepalli