我的java天地

枚举示例程序

 

 1 public   class  EnumTest  {
 2

 3      public   enum  MsgType 
{
 4         SMS( " this sms " ), LONGSMS( " this is longsms " ), MMS( " this is mms " ), WAP_PUSH( " this is wap push "
);
 5          private   final
 String index;
 6

 7          private  MsgType(String index) 
{
 8              this .index  =
 index;
 9         }

10
11         
/* public int getIndex() {
12
            return index;
13         } */

14
15          // 下面这段基本上不用

16          public   static  MsgType getType( int  index)  {
17              switch  (index) 
{
18              case   0
:
19                  return
 SMS;
20              case   1
:
21                  return
 LONGSMS;
22              case   2
:
23                  return
 MMS;
24              case   3
:
25                  return
 WAP_PUSH;
26              default
:
27                  return
 SMS;
28             }

29         }

30     }

31     
32
    
33      public   static   void  main(String []args)
{
34
        System.out.println(MsgType.SMS);
35         System.out.println(MsgType.getType( 0
));
36     }

37 }

38

posted on 2011-05-23 15:43 tobyxiong 阅读(227) 评论(0)  编辑  收藏 所属分类: java


只有注册用户登录后才能发表评论。


网站导航:
 
<2011年5月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234

导航

统计

常用链接

留言簿(3)

随笔分类(144)

随笔档案(157)

相册

最新随笔

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜