类初始化与对象初始化

what's the output?
/**
 * @author 031202
 *
 * TODO To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
class Parent {
 
 class InnerClass {
  public InnerClass() {
   System.out.println("Construct parent's inner class");
  }
 }
 
 static class StaticInner {
  public StaticInner() {
   System.out.println("Construct parent's StaticInner class");
  }
 }
 
 private InnerClass i = new InnerClass();
 
 private static StaticInner s = new StaticInner();
 
 public Parent() {
  System.out.println("Construct Parent");
 }

}

public class Child extends Parent {
 class InnerClass {
  public InnerClass() {
   System.out.println("Construct child's inner class");
  }
 }
 
 static class StaticInner {
  public StaticInner() {
   System.out.println("Construct child's StaticInner class");
  }
 }
 
 private static StaticInner s = new StaticInner();
 
 private InnerClass i = new InnerClass();
 
 public Child() {
  System.out.println("Construct Child");
 }
 
 public static void main(String[] args) {
  new Child();
 }
}
answer:
Construct parent's StaticInner class
Construct child's StaticInner class
Construct parent's inner class
Construct Parent
Construct child's inner class
Construct Child

Do you really understnand  the class initialization?

你可能感兴趣的:(class,templates,string,java,go,java基础)