Switch Vs If-else

Last updated:9/20/2020 2:52:46 PM

1 Answers

Prakash nidhi Verma
Prakash nidhi Verma

switch vs if else :

In switch every condition is given very clear and they execute directly from condition but if else check all condition line by line they don't reach directly on conditions. some points given below for differentiate them : 

1- Switch better for Multi way branching than if else 

2- if-else better for boolean values than switch.

3- Speed is better for switch than if-else.

4- Clarity in readability is better in switch.

5- Check Testing Expression is good in switch.

Answer