0
Switch
Is it possible for a switch case to work if we don't initialise the variable to 0?
3 odpowiedzi
+ 10
Whenever in doubt, just try it out on you own as you can always code it in the Code Playground straightaway.
Then you'll ask if you couldn't figure out why it works or not working. 😉
+ 1
Nope, if the variabile don't take any value during the execution of the code before the Switch, the statment Will receive a null element giving you an happy NullPointerException, so java want the variabile to be initialised
+ 1
Thnx