+ 1

Can we use switch case in Java like as we use in c and c++?

24th Aug 2017, 1:37 PM
Mukesh yadav
Mukesh yadav - avatar
3 Respuestas
+ 3
yes you can use switch case in Java too example : class SwitchDate{ public static void main(String[] args){ int week = 3; switch (week){ case 1: System.out.println("monday"); break; case 2: System.out.println("tuesday"); break; case 3: System.out.println("wednesday"); break; case 4: System.out.println("thursday"); break; case 5: System.out.println("friday"); break; case 6: System.out.println("saturday"); break; case 7: System.out.println("sunday"); break; default: System.out.println("Invalid week"); break; } } }
24th Aug 2017, 1:45 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 3
Yes and it's exactly has the same syntax as we use it in c++ The only difference is that the (printing statement will change)
24th Aug 2017, 2:12 PM
Shade96
Shade96 - avatar
+ 1
thanks a lot
24th Aug 2017, 2:20 PM
Mukesh yadav
Mukesh yadav - avatar