KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SwitchStmts


1 public class SwitchStmts {
2     public static void main (String JavaDoc [] args) {
3         for (int i = 0 ; i < 10; i++) {
4             switch (i) {
5             
6                 case 7 : {
7                              System.out.println("Hello");
8                              break;
9                              }
10                 case 2 : {
11                                System.out.println("Hi");
12                                break;
13                              }
14                 default: {
15                             System.out.println("Smile");
16                             break;
17                          }
18             }
19                 
20         }
21         for (int i = 0 ; i < 7; i++) {
22             switch (i) {
23                 case 0 : {System.out.println("Hello");
24                           break;}
25                 case 1 : {System.out.println("Hello");
26                           break;}
27                 case 4 : {System.out.println("Hello");
28                           break;}
29                 case 2 : {System.out.println("Hello");
30                           break;}
31                 case 5 : {System.out.println("Hello");
32                           break;}
33                 case 3 : {System.out.println("Hello");
34                           break;}
35                 default : {System.out.println("Hello");
36                           break;}
37             }
38         }
39     }
40 }
41
Popular Tags