Different between Switch/Switch Case Statement and Else if ladder
Switch/Switch Case Statement v/s Else if ladder :-
Switch/Switch Case Statement | Else if ladder |
1 . In case of switch case as per the value of the switch the control jumps to the corresponding case. | 1 . The control goes through the every else if statement until it finds true value of the else is ladder. |
2 . The switch case is more compact than lot of nested else…if so , switch is considered to be more readable. | 2 . The nested else..if is less compact than lot of switch. |
3 . The use of break statement in switch is essential. | 3 . There is no need of use of break in else if ladder. |
4 . Switch case statement work on the basis of equality operator. | 4 . Else if ladder works on the basis of true false basis. |
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment