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

          主站蜘蛛池模板: 商南县| 正阳县| 綦江县| 通榆县| 白山市| 湘潭县| 阿巴嘎旗| 策勒县| 拜泉县| 蕲春县| 西吉县| 二手房| 卢龙县| 汉阴县| 甘谷县| 渝北区| 神木县| 哈密市| 嵩明县| 延津县| 泰州市| 深州市| 镇坪县| 永城市| 台中县| 罗江县| 甘南县| 电白县| 慈溪市| 邛崃市| 宣化县| 苍溪县| 城步| 南汇区| 兴安县| 黔南| 金坛市| 翁源县| 广南县| 皮山县| 高陵县|