2015-09-21 84 views
-2

我有一個問題,我的代碼 我要指派一個簡單枚舉變量和eclipse給我一個錯誤「空不能得到解決或不是 場」分配一個枚舉變量

這裏是我的代碼 我有一個枚舉類種子象下面這樣:

public enum Seed { // to save as "Seed.java" 
    EMPTY, CROSS, NOUGHT 
} 

和我有裏面我想使用的種子類電池類:

public class Cell { 
    // Package access 
    Seed content; // content of this cell (Seed.EMPTY, Seed.CROSS, or Seed.NOUGHT) 
    int row, col; // row and column of this cell 

    /** Constructor to initialize this cell with the specified row and col */ 
    public Cell(int row, int col) { 
     this.row = row; 
     this.col = col; 
     clear(); // clear content 
    } 

    /** Clear this cell's content to EMPTY */ 
    public void clear() { 
     content = Seed.EMPTY;//**ERROR** EMPTY cannot be resolved or is not a field 
    } 
} 

有什麼不對?

+1

您提供的代碼編譯得很好。也許你已經在不同的軟件包中獲得了它們,或者你有另一個'Seed'類別的地方?如果我們只能看到工作代碼,我們無法提供幫助... –

+0

確保重新編譯'Seed'類,您可能正在運行較早的版本。 – Keppil

+0

從錯誤信息判斷,編譯器可以找到'Seed'類就好了,它找不到'EMPTY'字段。 – Keppil

回答

2

保存您的項目並構建它,錯誤將消失

+0

我不知道發生了什麼,但我關閉日食並再次運行它,所有錯誤也在我的應用程序的其他部分不見了:) .. 。 謝謝你們 –