switch能接受的数据类型int short byte char 及其封装类

 1 package cn.sice;
 2 
 3 public class SwtichDemo
 4 {
 5 
 6     public static void main(String[] args)
 7     {
 8         int x = 1;
 9         byte b = 2;
10         short s = 3;
11         char c = 4;
12         switch (c)
13         {
14         case 1:
15             System.out.println("int = " + x);
16             break;
17         case 2:
18             System.out.println("byte = " + x);
19             break;
20         case 3:
21             System.out.println("short = " + x);
22             break;
23         case 4:
24             System.out.println("char = " + x);
25             break;
26         case 5:
27             break;
28         default:
29             System.out.println("d");
30         }
31     }
32 
33 }

 

posted @ 2014-02-08 21:18  一路向北中  阅读(301)  评论(0)    收藏  举报