0
Switch statement need to have a "default" case? Or you can ignore it?
Just as the title says, do you must declare a default case in a switch statement? What happens if you don't set it and the program fall in a case not decleared?
3 Antworten
+ 5
default case only works when all of the other switch cases doesnt work.
If you do not put in a default case and all of the other switch cases dont work, then nothing will happen.
+ 2
if default statement is not declared and switch cannot match with any case it will exit ...
+ 1
default is like an else statement, you dont need an else statement in an if, same goes with default, you dont need it with a switch