【发布时间】:2014-10-02 02:29:22
【问题描述】:
我在 main 中有错误,谁能帮我找到错误所在?我正在尝试创建一个类并使用 setter/getter 来设置每个字段,最终我将测试这个类以确保这些字段正常工作
public class College{
public class person{
private String name;
private int age;
private double id;
//constructor to set fields
public Schedule (String name, int age, double id){
this.name= name;
this.age= age;
this.id= id;
}
public String getName(){
return this.name;
}
public void setName(String Name) {
this.name= name;
}
public int getAge(){
return this.Age;
}
public void setAge(int age) {
this.age = age;
}
public double getId(){
return this.id;
}
public void setId(double id) {
this.id = id;
}
}
public static void main(String[] args) {
Schedule Per1= new College("John", 2,2.0);
}
}
【问题讨论】:
-
您需要在 main 中显示您尝试实例化/操作类的代码。