- class Person
- {
- public String name;
- public int age;
- public Person(){}
- public Person(String name,int age)
- {
- this.name=name;
- this.age=age;
-
- }
- public void getIn()
- {
- System.out.println(name);
- System.out.println(age);
- //System.out.println(name,"age="+age);错
- }
- public void eat()
- {
- System.out.println("chifan");
- }
- }
- class Student extends Person
- {
- public String lesson;
- public Student(){}
- public Student(String name,int age)
- {
- super(name,age);
- }
- public Student(String name,int age,String lesson)
- {
- this(name,age);
- this.lesson=lesson;
- }
- public void less()
- {
- System.out.println("shangke");
- }
- /* public static void main(String[] args)
- {
- Student str=new Student();
- str.name="zhagsan";
- str.age=15;
- str.eat();
- str.getIn();
- str.less();
- }
- */
- }
- class TestStudent
- {
- public static void main(String[] args)
- {
- Student str=new Student();
- str.name="znagsan";
- str.age=15;
- str.eat();
- str.getIn();
- str.less();
-
- }
- }
复制代码
谁能帮我讲讲这里的错误。打印出name age. |