目標: 檢索另一個類中的Player類中定義的數組,以便對數組內容執行額外的操作;Java數組:我想創建兩個數組,每個數組保存3個int值
到目前爲止的代碼:
public class Players {
//attributes
private int [] Player1 = new int [3];
private int [] Player2 = new int [3];
private int round=Math.random();
//Constructor
public Players(int [] p1, int [] p2){
[] player1 = [] p1
[] player2 = [] p2
}
問題說明:沒有編制;
我可能是錯的,但我有一種感覺,你沒有遵循OOP標準。您應該創建一個'Player'類,然後在main方法中爲player1/2實例化它的兩個實例。 – turbo
可能的重複http://stackoverflow.com/questions/1200621/how-to-declare-an-array-in-java – Freak