This static Final super

This

  • this represents the instantiated object of the current class.
  • This calls the attribute in this class. If there is no such attribute in this class, it will continue to search from the parent class.
  • This calls the method in this class. If there is no such method in this class, it will continue to search from the parent class.
  • This can call the constructor in this class.

static***

Convenient to call (method/variable) without creating an object

  • In static methods 不能访问非静态成员方法和非静态成员变量, but in non-static member methods, static member methods/variables can be accessed
  • Static variables are also called static variables, 当且仅当在类初次加载时会被初始化,可以被修改
  • static code block: only in类加载的时候执行一次
  • As long as the loaded class first executes the static code block, and then executes the constructor, no matter the order.

Final: Final

  • Use final to modify attributes to represent constants, which can be assigned directly or in the construction method, but只能被赋值一次
  • Using the final modification method means that the method cannot be overridden, but it can be inherited. (Except those with a private modifier)
  • Use final to modify the class, which means that the class cannot be inherited.
  • Use final in the method parameter, and the parameter value cannot be modified inside the method.

Super

  • super represents a reference to the parent object.
  • super can call the properties and methods and construction methods of the parent class.

Guess you like

Origin blog.csdn.net/wlj1442/article/details/109369491