LoginSignup
0
0

More than 3 years have passed since last update.

Java問題「言語仕様」初期化子(1)

Last updated at Posted at 2020-09-19

変数の初期化順について

初期化子(1)
次のプログラムをコンパイル・実行するとどうなるか?


public class Knock012 {
    private static boolean flag;
    public static void main(String[] arguments) {
        System.out.println(flag);
    }
}
  • 私の回答
    コンパイルエラーとなる
    flagが定義されてないからエラーになる

- 答え

false が出力される。

falseが標準出力される。 論理値boolean型の初期値はfalseである。
単純に初期値があることを知りませんでした。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0