+ 1

write a Java program to illustrate the use of switch statement

answer pls

22nd Jul 2016, 3:53 AM
jeeva g
jeeva g - avatar
3 Answers
+ 3
Joe, you are missing default. If day is not in cases.
22nd Jul 2016, 8:59 AM
WPimpong
WPimpong - avatar
+ 2
Thank you Wachirakorn. I will fix it. I agree, switch statement must have a default or you can get error.
22nd Jul 2016, 11:00 AM
‎‏‎‏‎Joe
‎‏‎‏‎Joe - avatar
0
// switch public class Program { public static void main(String[] args) { int day = 3; switch(day) { case 1: System.out.println("Monday"); break; case 2: System.out.println("Tuesday"); break; case 3: System.out.println("Wednesday"); break; default: System.out.println("The other 4 days"); } } }
22nd Jul 2016, 7:32 AM
‎‏‎‏‎Joe
‎‏‎‏‎Joe - avatar