public class SwitchErrors
1: public class SwitchErrors
2: {
3: public static void main(String[] args)
4: {
5: Scanner keyboard = new Scanner(System.out);
6:
7: System.out.println("Key: 1=blue, 2=red, 3=green");
8: System.out.print("Enter an number and I'll return ");
9: System.out.print(" the corresponding color. ");
10: number = keyboard.nextInt();
11:
12: switch(number)
13: {
14: case 1:
15: System.out.println("You choose red!");
16: break;
17: case 2:
18: System.out.println("You choose blue!");
19: break;
20: case 3:
21: System.out.println("You choose green!");
22: default:
23: System.out.println("Color not available!");
24: break;
25: }
26:
27: }
28: }