更正方法getAge()的以下错误定义
public void getAge()
{
return age;
}
在此处粘贴您的答案:
public int getAge(int age)
{
return age;
}
标记:1之0
注释:
* Test 1 (0.0 out of 1)
Person.java:15: getAge(int) in Person cannot be applied to ()
String s = (p.getAge() == 16 ? "getAge() Correct" : "getAge() not Correct");
^
1 error
The output should have been:
getAge() Correct
This is what was actually produced:
Exception in thread "main" java.lang.NoClassDefFoundError: Person
而不是(int age)是否要我将其替换为String?
最佳答案
我相信您要寻找的正确代码是:
public int getAge()
{
return age;
}
基本上说getAge()不需要参数(您的错误是,您传入了一个整数参数),它将返回一个int类型的值。