-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
}
}
有什么不对?
您提供的代码编译得很好。也许你已经在不同的软件包中获得了它们,或者你有另一个'Seed'类别的地方?如果我们只能看到工作代码,我们无法提供帮助... –
确保重新编译'Seed'类,您可能正在运行较早的版本。 – Keppil
从错误信息判断,编译器可以找到'Seed'类就好了,它找不到'EMPTY'字段。 – Keppil