class FreshJuice {
// enum: 定义枚举类型
enum FreshJuiceSize{ SMALL, MEDIUM, LARGE }
FreshJuiceSize size;
}
public class test {
public static void main(String[] args){
FreshJuice juice = new FreshJuice();
juice.size = FreshJuice.FreshJuiceSize.MEDIUM;
System.out.println("hello world " + juice.size);
}
}
Java枚举类型简单使用
最新推荐文章于 2022-05-22 16:04:42 发布