Difference between “this” and“super” keywords in Java

前端 未结 9 1850
你的背包
你的背包 2020-11-27 03:00

What is the difference between the keywords this and super?

Both are used to access constructors of class right? Can any of you explain?

9条回答
  •  我在风中等你
    2020-11-27 03:40

    this is used to access the methods and fields of the current object. For this reason, it has no meaning in static methods, for example.

    super allows access to non-private methods and fields in the super-class, and to access constructors from within the class' constructors only.

提交回复
热议问题