error:constructor类Player中的Player不能应用于给定类型;
问题描述:
每当我编译代码时,我收到以下错误:
whenever I compile my code, I receive the following errors:
错误:类Player中的Player不能应用于给定类型;
error: constructor Player in class Player cannot be applied to given types;
,但不会列出任何类型。有问题的代码是
but it doesn't list any types. The code in question is
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类位于以下位置:
The Player class is found below:
public class Player {
public String[] name;
public Player(String inputname) {
name = inputname.split(" ");
}}
有人可以告诉我这里有什么问题吗?如果有帮助,在错误的行上,玩家[k]将是一个类似名字的字符串,如比利鲍勃。
Can someone please tell me what is wrong here? If it helps, on the line with errors, players[k] would be a name-like string, such as "Billy Bob."
答
players[k]
,并且你的构造函数是期望的String:
is of type Player, and your constructor is expecting String:
public Player(String inputname)