error:constructor类Player中的Player不能应用于给定类型; [英] error: constructor Player in class Player cannot be applied to given types;

查看:285
本文介绍了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) 

这篇关于error:constructor类Player中的Player不能应用于给定类型;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆