Java 中的枚舉類(enum)
一、常量使用java
![](http://static.javashuo.com/static/loading.gif)
二、switch3d
![](http://static.javashuo.com/static/loading.gif)
三、向枚舉類添加新的方法對象
- 必須在enum實例序列的最後添加一個分號
- 並且 Java 要求必須先定義 enum 實例
![](http://static.javashuo.com/static/loading.gif)
四、覆蓋方法blog
![](http://static.javashuo.com/static/loading.gif)
五、實現接口繼承
- 全部的枚舉都繼承自java.lang.Enum類
- 因此枚舉對象不能再繼承其餘類
![](http://static.javashuo.com/static/loading.gif)
六、使用接口組織枚舉接口
![](http://static.javashuo.com/static/loading.gif)
七、枚舉集合it
- java.util.EnumSet和java.util.EnumMap是兩個枚舉集合
- EnumSet保證集合中的元素不重複
- EnumMap中的 key是enum類型,而value則能夠是任意類型
歡迎關注本站公眾號,獲取更多信息