class Student extends Person {
    
    private String school;
    
    
    Student(String name, String location, String school) {
        super(name,location);
        this.school = school;
    }
Student 继承了Person类 ,super什么意思,一般 都是 super.什么 为什么super()用括号了呢 还有在API里怎么查到。

解决方案 »

  1.   

    调用父类的构造函数你有this(); 那就不能有super();啊.
      

  2.   

    super.那是调用基类的数据成员或方法。而super 是调用符合此参数的基类的构造器
      

  3.   

    我也知道 书里有,能不能告诉我在API文档里查什么关键字能查到这个方法的说明。谢谢了。
      

  4.   

    API 里恐怕也查不到 +-*/ 的说明吧
    super,this,就跟 +-*/ 一样,是最最基本的东西,和API无关
      

  5.   

    super()掉构造,
    super.调父类属性和方法
      

  6.   

    super(name,location)
    调Person类的构造
    super.methrod()
    调Person类的方法
      

  7.   

    有时会需要子类调用父类的中的方法情况,但是如果这时子类中方法与父类中的方法名相同,即子类覆盖了父类的中的方法,显然如果直接调用用方法名是调用子类重新实现的操作。如果想调用父类中的方法,就需要用到super关键字 例:
    super.变量名
    super.方法名(参数)
    super(参数)
      

  8.   

    super() 是调用父类的构造方法
    super.XX()  是调用父类的方法
    区分好这个就清楚了。