+ 4

java switch

Could you explain me... public class SwitchRv { public static void main(String[] args) { int miphone=2; switch (miphone) { case 1 :sdas: // why not error System.out.println("Middle"); break; case 2:Samsung: //why not error System.out.println("Good"); default: break; } } } https://code.sololearn.com/cF5WYE25N7u0/?ref=app

8th May 2019, 3:45 PM
Immortal Crow
Immortal Crow - avatar
8 Antworten
+ 7
Interesting, but I am not sure why this works. Danijel Ivanović Do you have an idea? Thanks for help :)
8th May 2019, 11:20 PM
Denise Roßberg
Denise Roßberg - avatar
+ 3
🙁🙁 I don't get it
10th May 2019, 6:18 AM
Immortal Crow
Immortal Crow - avatar
+ 2
(case 1: sdas:) why there is no error or is there other reason
8th May 2019, 4:25 PM
Immortal Crow
Immortal Crow - avatar
9th May 2019, 4:25 AM
Immortal Crow
Immortal Crow - avatar
+ 2
nais
9th May 2019, 11:53 PM
Awis
Awis - avatar
0
I can't understand the switch help
15th Oct 2020, 6:07 AM
Joseph Cooper
Joseph Cooper - avatar
0
I believed it worked because of the “Default” the default is automatically going to printout if all the case ve been tested and no Answer is found As you can see it printed out the default which says : Ok if none of the above are true Do this : ...
16th Apr 2021, 11:37 PM
Emmanuel Manu
Emmanuel Manu - avatar