Why can I not use “super” variable from a static context, even though “super” refers to the parent class and NOT a class instance, unlike “this”?

前端 未结 4 687
一向
一向 2020-12-28 21:09

I\'m talking java language.

Variable \"this\", when used inside a class, refers to the current instance of that class, which means you cannot use \"this\" inside a s

4条回答
  •  悲哀的现实
    2020-12-28 21:49

    No, super does refer to an instance -- the same instance that this refers to -- the current object. It's just a way to reference methods and fields in defined in the superclass that are overridden or hidden in the current class.

提交回复
热议问题