今日のひとこと Challange IT For Future

クラスの初期化

Java 読了 1分

この記事は最終更新から 18 年以上たっています。内容が現在の状況と異なる可能性があります。現在の情報は最新の記事、Fess の記事をご覧ください。

復習中・・・。

class Super {
static { System.out.print("Super "); }
}
class One {
static { System.out.print("One "); }
}
class Two extends Super {
static { System.out.print("Two "); }
}
class Test {
public static void main(String[] args) {
One o = null;
Two t = new Two();
System.out.println((Object)o == (Object)t);
}
}

とあって、java Test を実行したときの出力結果は?

説明は http://java.sun.com/docs/books/jls/third_edition/html/execution.html#44667 です。