码迷,mamicode.com
首页 > 编程语言 > 详细

Enum

时间:2016-12-18 09:42:20      阅读:188      评论:0      收藏:0      [点我收藏+]

标签:contract   static   技术   继承   exp   http   stat   使用   ase   

1.定义时使用enum关键字定义。

2.隐式继承了java.lang.Enum类,所以不能再继承其他类了。

3.隐式的final修饰符,所以不能被其他类继承。

技术分享
 1 package enumTest;
 2 
 3 public enum Week {
 4     MONDAY,
 5     TUESDAY,
 6     WEDNESDAY,
 7     THURSDAY,
 8     FRIDAY,
 9     SATURDAY,
10     SUNDAY;
11     
12     public static void main(String[] args)
13     {
14         Week day = Week.FRIDAY;
15         
16         switch(day)
17         {
18             case MONDAY:
19                 System.out.println("it is Monday! work hard!");
20                 break;
21             case TUESDAY:
22                 System.out.println("it is Tuesday! work hard hard!");
23                 break;
24             case WEDNESDAY:
25                 System.out.println("it is Wednesday! tired!");
26                 break;
27             case THURSDAY:
28                 System.out.println("it is Thursday! waiting weekend!");
29                 break;
30             case FRIDAY:
31                 System.out.println("it is Friday! will have a nice night!");
32                 break;
33             case SATURDAY:
34                 System.out.println("it is Saturday! lovely day!");
35                 break;
36             case SUNDAY:
37                 System.out.println("it is monday!oh no tomorrow is Monday again!");
38                 break;
39             default:
40                 System.out.println("it is monday! what!");
41                 
42         }
43     }
44 }
View Code

 

Enum

标签:contract   static   技术   继承   exp   http   stat   使用   ase   

原文地址:http://www.cnblogs.com/cici20166/p/6193665.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!