正確的方法getAge()下列錯誤定義爲什麼我不能從Java中的void函數返回值?
public void getAge()
{
return age;
}
在這裏你的答案貼:
public int getAge(int age)
{
return age;
}
馬克:0出1
評論:
* 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年齡)它是否要我用一個Strin替換它G?
只是刪除了參數,並挑選'this.age'。 – Davio 2015-02-01 13:05:42