📄 enumdemo3.java
字号:
/*
* 枚举是类类型
*/
enum Apple3 {
Jonathan(12), GoldenDel(22), RedDel, Winesap, Cortland(3);
private int price;
Apple3(int p) {
price = p;
}
private Apple3() {}
int getPrice() {
return price;
}
}
public class EnumDemo3 {
public static void main(String[] args) {
System.out.println("Winesap costs " + Apple3.Winesap.getPrice());
System.out.println("All apples prices:");
for (Apple3 a : Apple3.values()) {
System.out.println(a + " costs " + a.getPrice() + " cents");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -