现在我正在尝试用java制作玩具TicTacToe程序。
public class Board {
private enum Slot {
UNFILLED, FIRSTPLAYER, SECONDPLAYER
}
private Slot[][] board = {{"UNFILLED", "UNFILLED", "UNFILLED"}, {"UNFILLED", "UNFILLED", "UNFILLED"}, {"UNFILLED", "UNFILLED", "UNFILLED"}};
我声明了一个名为Slot的枚举,我正试图用这个枚举填充我的主板。这样做的正确语法是什么?
答案 0 :(得分:3)
您可以使用:
private Slot[][] board = {{Slot.UNFILLED, ...
或
private Slot[][] board = {{UNFILLED, ...
在这种情况下,您需要添加静态导入:import static your.package.Board.Slot.*;