雖然我仍然是一個新手程序員,但在初始化對象時我相當有信心。然而,我不能爲了我的生活找出爲什麼我在這段代碼中出現錯誤。有人可以幫我嗎?該線:球員球員=新球員(「菲爾」,[0] [0],假);是我遇到錯誤的地方。無法爲玩家對象分配值?
public class Players {
private String player;
private int [][] position;
private boolean turn;
public static void main(String[]args){
Players player = new Players("Phil", [0][0] , false);
}
public Players(String player, int[][] position, boolean turn){
this.player = player;
this.position = position;
this.turn = turn;
}
public String getPlayer(){
return player;
}
public void setPlayer(String player){
this.player = player;
}
public int [][] getPosition(){
return position;
}
public void setPosition(int [][] position){
this.position = position;
}
public boolean getTurn(){
return turn;
}
public void setTurn(boolean turn){
this.turn = turn;
}
}
從長遠來看,我認爲這可能是我想要走的路。謝謝! –