我创建了一个类文件和一个测试器文件。当我尝试使用构造函数创建对象时,它不会编译。
它说“PassTheClassTester.java:5:错误:PassTheClass 类中的构造函数 PassTheClass 不能应用于给定类型;”
请帮忙。这是我的代码:
public class PassTheClass
{
private String myName = " ";
private int myGrade;
private String myEmotion = " ";
public PassTheClass (String xMyName, String xMyEmotion)
{myName = xMyName;
myGrade = 0;
myEmotion = xMyEmotion;}
public String getMyName()
{return myName;}
public int getMyGrade()
{return myGrade;}
public String getMyEmotion()
{return myEmotion;}
public void setMyName (String yMyName)
{myName = yMyName;}
public void setMyGrade (int yMyGrade)
{myGrade = yMyGrade;}
public void setMyEmotion (String yMyEmotion)
{myEmotion = yMyEmotion;}
}
public class PassTheClassTester
{
public static void main(String[] args)
{
PassTheClass demo = new PassTheClass("Squidward",94,"proud");
System.out.println(student.getMyName());
}
}