1) Access to superclass private fields using the super keyword in a subclass
I am completely fine with this working. I also noticed that it seems to work with data being marked as protected instead of private and not using the super keyword. I am mostly interested in any documentation mentioning this ability of the super keyword.
I am completely fine with this working. I also noticed that it seems to work with data being marked as protected instead of private and not using the super keyword. I am mostly interested in any documentation mentioning this ability of the super keyword.
abstract class OuterClass {
protected class NestedSuperClass<T> {
private T data;
public NestedSuperClass (T t) {
this.data = t;
}
public T getOutput() {
return data;
}
}
protected class NestedSubClass<T> extends NestedSuperClass<T> {
public NestedSubClass (T t) {
super(t);
}
protected void setOutput(T t) {
super.data = t;
}
}
}
No comments:
Post a Comment