美文网首页
super&this

super&this

作者: White夏天baby | 来源:发表于2021-06-21 23:52 被阅读0次

this调用当前类中允许被访问的属性与方法
super调用父类中允许被访问的属性与方法
this与super不能在静态方法中使用
放在带参构造方法第一行的this()方法,会优先调用同一个类中的无参构造方法

无参构造方法调用时,this()与super()不能同时出现

相关文章

  • super&this

    this调用当前类中允许被访问的属性与方法super调用父类中允许被访问的属性与方法this与super不能在静态...

网友评论

      本文标题:super&this

      本文链接:https://www.haomeiwen.com/subject/rxtpyltx.html