对象的设置方法错误
Error in set methods for object
不太清楚为什么,但 eclipse 对我的 setter 方法产生错误,读取 "Syntax error, insert "...VariableDeclaratoid" to complete FormalParamaterList."
这是我的代码:
public class Student {
public int id;
public String name;
Student() {
}
public int getID() {
return id;
}
public void setID(i) {
this.id = i;
}
public String getName() {
return name;
}
public void setName(n) {
this.name = n;
}
public String toString() {
System.out.println("The student's name is: " + this.name);
System.out.println("The student's ID is: " + this.id);
}
}
因为你没有给你的参数 i
和 n
它们的类型。见下文
public void setID(int i) {
this.id = i;
}
public void setName(String n) {
this.name = n;
}
不太清楚为什么,但 eclipse 对我的 setter 方法产生错误,读取 "Syntax error, insert "...VariableDeclaratoid" to complete FormalParamaterList."
这是我的代码:
public class Student {
public int id;
public String name;
Student() {
}
public int getID() {
return id;
}
public void setID(i) {
this.id = i;
}
public String getName() {
return name;
}
public void setName(n) {
this.name = n;
}
public String toString() {
System.out.println("The student's name is: " + this.name);
System.out.println("The student's ID is: " + this.id);
}
}
因为你没有给你的参数 i
和 n
它们的类型。见下文
public void setID(int i) {
this.id = i;
}
public void setName(String n) {
this.name = n;
}