質問編集履歴
1
ソースの誤字や{}の全角半角についてご指摘がありましたので修正いたしました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -12,21 +12,23 @@
|
|
12
12
|
|
13
13
|
```Java
|
14
14
|
|
15
|
-
classItem{
|
15
|
+
class Item{
|
16
16
|
|
17
17
|
String name;
|
18
18
|
|
19
|
-
public
|
19
|
+
public Item(String name) {
|
20
20
|
|
21
21
|
this.name = name;
|
22
22
|
|
23
|
-
|
23
|
+
}
|
24
24
|
|
25
|
-
|
25
|
+
}
|
26
|
+
|
27
|
+
|
26
28
|
|
27
29
|
public class Sample {
|
28
30
|
|
29
|
-
public static void main(String[] args)
|
31
|
+
public static void main(String[] args) {
|
30
32
|
|
31
33
|
Item[] items =new Item[3];
|
32
34
|
|
@@ -58,29 +60,29 @@
|
|
58
60
|
|
59
61
|
public class Sample {
|
60
62
|
|
61
|
-
|
63
|
+
public static final int length = 3;
|
62
64
|
|
63
|
-
|
65
|
+
public static void main(String[] args) {
|
64
66
|
|
65
|
-
|
67
|
+
int[] array = new int[length];
|
66
68
|
|
67
|
-
|
69
|
+
for(int i = 0; i < 3; i++){
|
68
70
|
|
69
|
-
|
71
|
+
System.out.print(array[i]);
|
70
72
|
|
71
|
-
|
73
|
+
}
|
72
74
|
|
73
|
-
|
75
|
+
System.out.println();
|
74
76
|
|
75
|
-
|
77
|
+
Integer[] array2 = new Integer[length];
|
76
78
|
|
77
|
-
|
79
|
+
for(int i =0; i < 3; i++){
|
78
80
|
|
79
|
-
|
81
|
+
System.out.print(array2[i]);
|
80
82
|
|
81
|
-
|
83
|
+
}
|
82
84
|
|
83
|
-
|
85
|
+
}
|
84
86
|
|
85
87
|
}
|
86
88
|
|