1
6 public class Switch {
7
8 public static int swicth_testi(int x,int operaatio) {
9 switch (operaatio) {
10 case 5:
11 case 4: x *= 2; break;
12 case 3: x += 2;
13 case 2: x++;
14 case 1: x++; break;
15 default: x=0; break;
16 }
17 return x;
18 }
19
20 private static void testaa(int x, int operaatio) {
21 int tulos = swicth_testi(x,operaatio);
22 System.out.println("x = " + x + " operaatio = " + operaatio +
23 " => " + tulos);
24 }
25
26 public static void main(String[] args) {
27 for (int i=0; i<7; i++) testaa(3,i);
28 }
29 }
30