public class A {
public A() {
doSomething();
}
protected void doSomething() {
System.out.println("Saying something from A");
}
public static class B extends A {
private String hello = new String("Hello my friend!");
public B() {
super();
}
@Override
protected void doSomething() {
System.out.println("Saying from B: " + hello);
}
}
public static void main(String[] args) {
new B();
}
}
Daí quando executo:
C:\java>java A
Saying from B: null
Trivial né?