Enum are Class Types
来源:互联网 发布:mac 浅色文件夹打不开 编辑:程序博客网 时间:2024/05/29 10:50
* don't instantiate a enum using new *///Use an enum Constructor, instance variable, and method.enum Apple{ Jonathan(10), GoldenDel(9), RedDel(12), Winesap(15), Cortland(8); private int price; //contructor Apple(int p) { price= p;} //Overloaded constructor Apple() { price= -1;} int getPrice(){return price;}}class EnumDemo3{ public static void main(String args[]) { Apple ap; //Display price of Winesap. System.out.println("Winesap costs "+ Apple.Winesap.getPrice()+ " cents.\n"); //Display all apples and prices. System.out.println("All apple prices: "); for(Apple a: Apple.values()) System.out.println(a+" costs"+ a.getPrice()+ " cents."); }}
0 0
- Enum are Class Types
- Enum Types in java
- Java Enum Types
- enum 与enum class
- Enum Class
- my java enum class
- c++11 enum class
- c++11 enum class
- 九,Enum Class
- ES6 class enum function
- enum,struck与class
- c++11 class enum
- JS.Class - 2. Methods & Types
- Four types of inner class
- What are the Types of Inforecords
- 'Blocks HTML' Cache Types are invalidated
- What are the Microsoft Office MIME Types
- [转]Enum还是Enum Class(枚举类)
- CCF之模版生成系统(java)
- VS2013/MFC编程入门之三十八(文档、视图和框架:分割窗口)
- 中国社会阶层划分
- 完全背包总结
- centOS6.5 配置vim
- Enum are Class Types
- laravel5.2session的使用
- http 通信协议
- C语言 + GTK3+ Visual Studio 2015环境配置 以及第一个GTK界面程序
- 1009. 说反话 (20)
- Android-Activity
- 【C语言简单说】二:第一个C语言程序详解(2)
- Plugin with id 'com.android.application' not found.
- 压缩流的简单应用