每當我編譯我的代碼,我收到以下錯誤:錯誤:構造函數類Player中的Player不能應用於給定的類型;
error: constructor Player in class Player cannot be applied to given types;
,但它沒有列出任何類型。有問題的代碼是
public class Team {
private String name;
public Player players[];
public Player temp;
public Team(String inputname, Player players[]) {
inputname = name;
this.players = new Player [players.length];
for(int k=0 ; k<players.length ; k++)
this.players[k] = new Player(players[k]); //This is the line with errors.
}
Player類如下發現:
public class Player {
public String[] name;
public Player(String inputname) {
name = inputname.split(" ");
}}
有人能告訴我這裏有什麼問題?如果有幫助,在出現錯誤的情況下,球員[k]將會是一個像名字一樣的字符串,比如「比利鮑勃」。
非常感謝的第k索引的構造的對象!修改我的代碼以從Strings創建Player對象,現在它工作得很好。 – 2012-03-28 23:51:20