概要
Javaで「多次元配列の初期化」の動作を確認してみました。
以下のページを参考にしました。
実装
以下のファイルを作成しました。
JSample8_1.java
class JSample8_1{
public static void main(String[] args){
int[][] num = {{87,54,67}, {76,92,48}};
for (int i = 0; i < 2; i++){
for (int j = 0; j < 3; j++){
System.out.println("num[" + i + "][" + j + "] = " + num[i][j]);
}
}
}
}
以下のコマンドを実行しました。
$ javac JSample8_1.java
$ java JSample8_1
num[0][0] = 87
num[0][1] = 54
num[0][2] = 67
num[1][0] = 76
num[1][1] = 92
num[1][2] = 48
まとめ
何かの役に立てばと。