existantial question
if i have a class hierarchy like:
public class TestSuper {
public static class A {
@Override
public String toString() { return "I am A"; }
}
public static class B extends A {
@Override
public String toString() { return "I am B"; }
}
public static void main(String[] args) {
Object o = new B();
System.out.println( o ); // --> I am B
// ?????? // --> I am A
}
}
From the main method, is it possible to call the toString of A when the instance is of type B ???
of course, something like o.super.toString() doesn't compile ...
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…