In all the tutorials for the super keywords that I found on the Internet, itβs hard to come close to the following examples. My question is:
Subclass
:
package test; public class Tracker extends test.parent.Tracker { @Override public void track(final Event event) { Executor.execute(new Runnable() { public void run() { Tracker.super.track(event);
Super class
package test.parent; public abstract class Tracker { public void track(Event event) {} }
Help updates:
In jls8, 11.15.2
"Suppose that the access class expression T.super.f appears in class C, and the immediate superclass of the class, denoted by T, is a class whose full name is S. If f from S is accessible from C, then T.super.f is processed like this as if it were the expression this.f in the body of class S. Otherwise, a compile-time error occurs.
Thus, T.super.f can access the field f available in class S, even if this field is hidden by the declaration of the field f in class T.
This is a compile-time error if the current class is not an inner class of the class T or T.
source share