回答編集履歴
3
ソース追記
test
CHANGED
@@ -5,3 +5,63 @@
|
|
5
5
|
int [][] a = {{0,0,0,0},{0,0,0,0},{0,0,0,0}};
|
6
6
|
|
7
7
|
参考:[Java配列の初期化大辞典!](https://engineer-club.jp/java-array-initialization)
|
8
|
+
|
9
|
+
・・・追記・・・
|
10
|
+
|
11
|
+
```java
|
12
|
+
|
13
|
+
public static void main(String[] args) {
|
14
|
+
|
15
|
+
// TODO code application logic here
|
16
|
+
|
17
|
+
int [][] a = {{0,0,0,0},{0,0,0,0},{0,0,0,0}};
|
18
|
+
|
19
|
+
// TODO code application logic here
|
20
|
+
|
21
|
+
for (int[] a1 : a) {
|
22
|
+
|
23
|
+
for(int x: a1){
|
24
|
+
|
25
|
+
System.out.println(x);
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
}
|
30
|
+
|
31
|
+
}
|
32
|
+
|
33
|
+
```
|
34
|
+
|
35
|
+
結果
|
36
|
+
|
37
|
+
```text
|
38
|
+
|
39
|
+
run:
|
40
|
+
|
41
|
+
0
|
42
|
+
|
43
|
+
0
|
44
|
+
|
45
|
+
0
|
46
|
+
|
47
|
+
0
|
48
|
+
|
49
|
+
0
|
50
|
+
|
51
|
+
0
|
52
|
+
|
53
|
+
0
|
54
|
+
|
55
|
+
0
|
56
|
+
|
57
|
+
0
|
58
|
+
|
59
|
+
0
|
60
|
+
|
61
|
+
0
|
62
|
+
|
63
|
+
0
|
64
|
+
|
65
|
+
BUILD SUCCESSFUL (total time: 0 seconds)
|
66
|
+
|
67
|
+
```
|
2
誤記修正
test
CHANGED
@@ -2,6 +2,6 @@
|
|
2
2
|
|
3
3
|
宣言+初期化
|
4
4
|
|
5
|
-
int
|
5
|
+
int [][] a = {{0,0,0,0},{0,0,0,0},{0,0,0,0}};
|
6
6
|
|
7
7
|
参考:[Java配列の初期化大辞典!](https://engineer-club.jp/java-array-initialization)
|
1
追記
test
CHANGED
@@ -1 +1,7 @@
|
|
1
1
|
int a[][] = [3][4];→int [][] a= new int[3][4];
|
2
|
+
|
3
|
+
宣言+初期化
|
4
|
+
|
5
|
+
int a[][] = {{0,0,0,0},{0,0,0,0},{0,0,0,0}};
|
6
|
+
|
7
|
+
参考:[Java配列の初期化大辞典!](https://engineer-club.jp/java-array-initialization)
|