我有一个语法错误,我不知道如何修复它。代码对我来说似乎是正确的,但 Eclipse 告诉我“构造函数调用必须是构造函数中的第一条语句”在方法setName()
和setAge()
public class KeywordThis {
private String name;
private int age;
public KeywordThis(){
this.name = "NULL";
this.age = 0;
}
public KeywordThis(String s, int a){
this.name = s;
this.age = a;
}
public KeywordThis(String s){
this.name = s;
}
public KeywordThis(int a){
this.age = a;
}
public int setAge(int a){
this(a);
}
public String setName(String s){
this(s);
}
public static void main(String args[] ){
}
}