love fish大鵬一曰同風起,扶搖直上九萬里

          常用鏈接

          統計

          積分與排名

          friends

          link

          最新評論

          類初始化與對象初始化 (轉)

          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 閱讀(314) 評論(0)  編輯  收藏 所屬分類: Java

          主站蜘蛛池模板: 囊谦县| 福泉市| 佛山市| 大厂| 朝阳区| 汉寿县| 泰顺县| 泸定县| 西藏| 阜新市| 湖南省| 武定县| 滦南县| 大丰市| 霞浦县| 济源市| 巫溪县| 右玉县| 阳高县| 阿克| 和平区| 永昌县| 乐业县| 龙川县| 牙克石市| 屏东市| 光山县| 盱眙县| 剑阁县| 太原市| 电白县| 鄂温| 溧阳市| 京山县| 北川| 阿拉善右旗| 永登县| 南投市| 鄂伦春自治旗| 武功县| 集安市|