分配一个枚举变量

时间:2015-09-21 08:57:24

标签: java enums

我的代码有问题 我想分配一个简单的枚举变量和eclipse给我一个错误“EMPTY无法解决或不是  字段“

这是我的代码 我有一个类似下面的枚举种子:

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 个答案:

答案 0 :(得分:2)

保存项目并构建它,错误将消失

相关问题