/Users/lyon/j4p/src/bookExamples/ch05ControlStructs/CaseDemo.java

1    package bookExamples.ch05ControlStructs; 
2     
3    public class CaseDemo { 
4        public static void main(String args[]) { 
5            CaseDemo cd = new CaseDemo(); 
6            cd.run('['); 
7            cd.run('('); 
8            cd.run('{'); 
9        } 
10    
11       public void run(char c) { 
12    
13           switch (c) { 
14               case '(': 
15                   println(c + "=leftParen"); 
16                   break; 
17               case '[': 
18                   println(c + "=leftBracket"); 
19                   break; 
20               default: 
21                   println(c + "=unknown symbol"); 
22                   break; 
23           } 
24       } 
25    
26       public void println(Object o) { 
27           System.out.println(o); 
28       } 
29   }