2016-04-21 42 views

回答

6

單上面的方法聲明說明如下,

// To maintain full signature compatibility with 1.5, and to improve the 
// clarity of the generated javadoc (see 6287639: Abstract methods in 
// enum classes should not be listed as abstract), method convert 
// etc. are not declared abstract but otherwise act as abstract methods. 

這裏,6287639是錯誤ID它說,

JDK-6287639:枚舉類抽象方法不應該被列爲抽象

現在考慮下面的enum將其視爲類,每枚舉常量爲Object,很顯然,如果我們創建的抽象的東西Object我們必須提供執行和避免這種convert不是abstract

enum Blocks { 
    A1, B1, C1; 
    // It will say enum constant must implement 
    // the abstract method test 
    abstract int test(); 
} 
+0

謝謝!但這個類(TimeUnit)的一些是抽象的,有些不是 –

相關問題