[Java]枚举、注解、异常和常用类
一、枚举
1. 自定义枚举类
枚举是一组常量的集合,属于一种特殊的类,里面只包含一组有限的特定的对象自定义枚举类:构造器私有化、不提供 setXxx() 方法、对枚举属性使用 statc + final 修饰以实现底层优化
class Season {
private final String name;
private final String description;
public static final Season SPRING = new Season("春天", "温暖");
public static final Season SUMMER = new Season("夏天", "炎热");
public static final Season AUTUMN = new Season("秋天", "凉爽");
public static fin
共有 0 条评论