1.super()和this()区别:   

                            super():调用父类无形参的构造方法;

                            super(形参):调用父类中某个带形参的构造方法;

                            this(形参):调用本类中另一种形式的构造方法;

          注意:放在方法的首行;

2.super和this的区别:

          super.父类的成员变量;

          super.父类的方法;

          super:当子类中的成员变量、方法和父类的相同时,实现调用父类的成员变量和方法;

          this:代表当前的对象;

                                   使用的地方:若函数的形参和成员变量同名时,需要用this.成员变量名

 

原文出处:

sunruntheway,  https://www.cnblogs.com/sunruntheway/p/sunruntheway.html

 
 

相关文章:

  • 2022-12-23
  • 2021-12-27
  • 2022-12-23
  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-18
  • 2022-02-02
  • 2021-07-04
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案