質問編集履歴
1
ソースの誤字や{}の全角半角についてご指摘がありましたので修正いたしました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -5,14 +5,15 @@
|
|
5
5
|
<事象>
|
6
6
|
ケース①
|
7
7
|
```Java
|
8
|
-
|
8
|
+
class Item{
|
9
9
|
String name;
|
10
|
-
public
|
10
|
+
public Item(String name) {
|
11
11
|
this.name = name;
|
12
|
-
|
12
|
+
}
|
13
|
-
|
13
|
+
}
|
14
|
+
|
14
15
|
public class Sample {
|
15
|
-
public static void main(String[] args)
|
16
|
+
public static void main(String[] args) {
|
16
17
|
Item[] items =new Item[3];
|
17
18
|
items[1] = new Item("A");
|
18
19
|
items[2] = new Item("B");
|
@@ -28,18 +29,18 @@
|
|
28
29
|
ケース②
|
29
30
|
```Java
|
30
31
|
public class Sample {
|
31
|
-
|
32
|
+
public static final int length = 3;
|
32
|
-
|
33
|
+
public static void main(String[] args) {
|
33
|
-
|
34
|
+
int[] array = new int[length];
|
34
|
-
|
35
|
+
for(int i = 0; i < 3; i++){
|
35
|
-
|
36
|
+
System.out.print(array[i]);
|
36
|
-
|
37
|
+
}
|
37
|
-
|
38
|
+
System.out.println();
|
38
|
-
|
39
|
+
Integer[] array2 = new Integer[length];
|
39
|
-
|
40
|
+
for(int i =0; i < 3; i++){
|
40
|
-
|
41
|
+
System.out.print(array2[i]);
|
41
|
-
|
42
|
+
}
|
42
|
-
|
43
|
+
}
|
43
44
|
}
|
44
45
|
```
|
45
46
|
|