我完全不懂Java,所以如果我的问题很蠢,请原谅。我正在完成一个作业,已经读了几个小时关于主方法的知识,但我还是弄不明白。我在下面放了一些代码。可能离题很远,但我希望实现的是让主方法启动构造函数,但编译时出现错误:“找不到符号-构造函数Player”。我猜测这与构造函数的字符串参数有关,但我已经想不出了。如果有人能解决这个简单的问题,我会非常高兴:)
public class Player {
private String nick;
private String type;
private int health;
public static void main(String[] args)
{
Player player = new Player();
player.print();
}
public Player(String nickName, String playerType)
{
nick = nickName;
type = playerType;
health = 100;
System.out.println("Welcome " + nick +" the " + type + ". I hope you are ready for an adventure!");
}
public void print()
{
System.out.println("Name: " + nick);
System.out.println("Class: " + type);
System.out.println("Remanining Health: " + health);
}