????????????????????о???????????????????????????????????????????????????β???????????£???????????????Java????????????м????????????????

/**
  * ????Foo????????????
  *
  * @author youngto
  * @since 2013-01-25
  */
 class Foo {
 
     private int index = 100;
   
     //????????
     static {      
         System.out.println("Foo static");
     }
   
     //??????????
     {      
         System.out.println("Foo initialization");
     }
   
     public Foo() {
         System.out.println("Foo constructor");
         System.out.println(printIndex());
     }
   
     protected int printIndex() {
         return index;
     }
   
 }
 
 /**
  * ????Bar????????????
  *
  * @author youngto
  * @since 2013-01-25
  */
 public class Bar extends Foo{
   
     private int index = 100;
     static Bar bar = new Bar();
   
     //????????
     static{
         System.out.println("Bar static");
     }
   
     //??????????
     {
         System.out.println("Bar initialization");
     }
   
     public Bar() {
        System.out.println("Bar constructor");
        System.out.println(printIndex());
     }
   
     @Override
     protected int printIndex() {
         System.out.println(bar);
         return index;
     }
   
     public static void main(String[] args) {
         Foo foo = new Bar();
         System.out.println(foo.printIndex());
         foo = new Bar();
     }
 
 }

????????????????С????????????????????????????????????

????a????heap??з?????棬??????????? instance ??????????????????? superclasses????????????(implementation-specific data)????ν????????????????????“class and method data?????

????b?? ?????Instance????????????????????????

????c??????most derived class??????????????????(constructor)(?????????????????.class????е????initialization method??????????????滻???Initialization method?????<init>????????????Java????????????.class????????а???[??????????]??[instance??????????????]?????[????superclass Initialization method]?????)???????????????????????superclass???????????????????????????? java.lang.object??????????????????????????java.lang.object?????java?????base class??

????d?????ж??????????????????????У??????????????

????e???????????????????????? instance ?????????趨?(initializers)????????(initialization blocks)??????У???????й????????塣????base class???????????У?most derived class???????????С???????κ?class???????????????????????κ?superclass ??instance ??????