找不到错误

时间:2014-10-02 02:29:22

标签: class field

我在主要有错误可以帮助我找到错误的位置吗?我正在尝试创建一个类并使用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);



    }


}

1 个答案:

答案 0 :(得分:0)

我想您可能想了解如何正确创建类。 以下链接可以帮助您(在C#中):

  

http://msdn.microsoft.com/en-us/library/x9afc042.aspx

public class person{

    private String name;
    private int age;
    private double id; 
    //constructor to set fields 
    public person(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) {


    person Per1= new person("John", 2,2.0);



}