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 static method.
But “super”, when used inside a class, refers to the superclass of that class, not an instance of the superclass, which should mean that you can use “super” inside a static method. But it turns out you cannot.
A possible explanation would be to say that “super” also refers to an instance of the superclass, but I can’t see why it should…
Here is the section in the JLS about the
super.Identifierrefers to the field named Identifier of the current object, but with the current object viewed as an instance of the superclass of the current class.
T.super.Identifierrefers to the field named Identifier of the lexically enclosing instance corresponding to T, but with that instance viewed as an instance of the superclass of T.
In both cases, it is clear that an instance object is needed.
Also, a static context is somewhat different from an instance context, as a class can’t override static methods, only hide them.