0
What is "break"in switch/case?
2 Answers
+ 3
It makes sure the next cases are skipped. Without break, the program would run all of the cases after a case that is true.
+ 1
IT IS SIMILAR TO ELSE-IF STATEMENT.
IN SWITCH STATEMENT YOU ARE PASSING A VALUE AND SEE IF ANY CASE MATCHES THAT VALUE IF YES YOU EXECUTE THAT BLOCK AND BREAK OUT FROM SWITCH STATEMENT.
IF ANY CASE DOESNT MATCH WITH VALUE DEFAULT CASE IS EXECUTED WHICH IS SIMILAR TO ELSE IN ELSE-IF.
I had tried to explain whole switch statement so you can get a clear idea.
Hope this helps âșïžâșïž.



