love fish大鵬一曰同風(fēng)起,扶搖直上九萬(wàn)里

          常用鏈接

          統(tǒng)計(jì)

          積分與排名

          friends

          link

          最新評(píng)論

          類初始化與對(duì)象初始化 (轉(zhuǎn))

          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?


          posted on 2007-03-16 17:07 liaojiyong 閱讀(322) 評(píng)論(0)  編輯  收藏 所屬分類: Java

          主站蜘蛛池模板: 宁陵县| 元江| 甘谷县| 新津县| 兴山县| 黔西| 禹城市| 筠连县| 河北省| 滦南县| 云霄县| 龙山县| 禹城市| 马龙县| 奉节县| 海口市| 惠东县| 遂川县| 无极县| 商洛市| 涟源市| 喀喇沁旗| 武义县| 阿尔山市| 丰台区| 林芝县| 农安县| 宁河县| 诸城市| 哈巴河县| 湘潭县| 固安县| 张家界市| 卓尼县| 阿拉善盟| 辰溪县| 射洪县| 班玛县| 富蕴县| 尚志市| 喀喇沁旗|