Learn Java for Android Development Second Edition 笔记(七)
来源:互联网 发布:linux l2tp 编辑:程序博客网 时间:2024/05/02 01:36
Mastering Enums
传统枚举类型有些问题,如下例子:
class Coin{final static int PENNY = 0;final static int NICKEL = 1;final static int DIME = 2;final static int QUARTER = 3;}class Weekday{final static int SUNDAY = 0;final static int MONDAY = 1;final static int TUESDAY = 2;final static int WEDNESDAY = 3;final static int THURSDAY = 4;final static int FRIDAY = 5;final static int SATURDAY = 6;}以上两个枚举类型变量缺乏安全检查,例如Coin.NICKEL == Weekday.MONDAY,数值上相等,但实际上不能互相比较。
Java5以后提供了一种新的数据类型enum,
0 0
- Learn Java for Android Development Second Edition 笔记(七)
- Learn Java for Android Development Second Edition 笔记(一)
- Learn Java for Android Development Second Edition 笔记(二)
- Learn Java for Android Development Second Edition 笔记(三)
- Learn Java for Android Development Second Edition 笔记(四)
- Learn Java for Android Development Second Edition 笔记(五)
- Learn Java for Android Development Second Edition 笔记(六)- Interface
- Learning ROS for Robotics Programming Second Edition学习笔记(七) indigo PCL xtion pro live
- JAVA线程——选自《Learn Java for Android Development》
- Learn Java for Android Development (第三版)---封面
- Learn Java for Android Development (第三版)---简介
- Pro Drupal Development, Second Edition
- Linux kernel Development second Edition
- 《Effective Java》Second Edition中文版笔记(完整)
- 3D Math Primer for Graphics and Game Development Second Edition
- Pro Java Programming, Second Edition
- Java Swing, Second Edition [ILLUSTRATED]
- Pro Java Programming, Second Edition
- WebService之CXF注解之一(封装类)
- animator 的参数默认值,Speed
- 二叉树的建立与遍历(山东理工OJ)
- iOS交互之翻转屏幕
- php获取近几日、月时间
- Learn Java for Android Development Second Edition 笔记(七)
- 基于ZF中的.htaccess文件学习Apache的Rewrite语法
- Ubuntu14.04下安装JDK8
- 如何写好PRD(产品需求文档)+范例
- Hdu 2196 Computer (树的直径 或 树形DP)
- 怎么才能婉转地拒绝别人的告白
- WebService之CXF注解之二(Service接口)
- paip.自适应网页设计 跟 响应式 设计方法与工具补充(2)o54
- java中的++运算符