???????Java???????????
???????????? ???????[ 2013/6/18 10:06:47 ] ????????
????????????????????о???????????????????????????????????????????????????β???????????£???????????????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 ??????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11