回答編集履歴
3
Integerクラスも配列作成式で許容されるので回答文を修正
answer
CHANGED
@@ -1,4 +1,13 @@
|
|
1
|
+
> double numStudents;
|
2
|
+
//中略
|
3
|
+
numStudents = keyboard.nextDouble();
|
4
|
+
tests = new double[numStudents];
|
5
|
+
String[] names = new String[numStudents];
|
6
|
+
|
7
|
+
質問文のtests = new double[numStudents];の行で配列作成式により配列を作成していますが、
|
1
|
-
Java言語の配列
|
8
|
+
Java言語の配列作成式はint型またはIntegerクラスの0から始まる正の整数値しか許容しません。
|
9
|
+
|
10
|
+
|
2
11
|
よって、
|
3
12
|
> double numStudents;→行を削除
|
4
13
|
|
@@ -9,4 +18,5 @@
|
|
9
18
|
他にも色々ソースコード上の問題がありますが、IDEのeclipseを入れてデバック実行して確認してみるのがいいと思います。
|
10
19
|
|
11
20
|
□参考情報
|
12
|
-
[Scanner#nextLine](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Scanner.html#nextLine--)
|
21
|
+
[Scanner#nextLine](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Scanner.html#nextLine--)
|
22
|
+
[15.10.1. Array Creation Expressions](https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.10.1)
|
2
typo
answer
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
↓
|
7
7
|
int numStudents = Integer.parseInt(keyboard.nextLine());
|
8
8
|
|
9
|
-
他にも色々ソースコード上の問題がありますが、IDE
|
9
|
+
他にも色々ソースコード上の問題がありますが、IDEのeclipseを入れてデバック実行して確認してみるのがいいと思います。
|
10
10
|
|
11
11
|
□参考情報
|
12
12
|
[Scanner#nextLine](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Scanner.html#nextLine--)
|
1
nextLineに変更
answer
CHANGED
@@ -4,6 +4,9 @@
|
|
4
4
|
|
5
5
|
> numStudents = keyboard.nextDouble();
|
6
6
|
↓
|
7
|
-
int numStudents = keyboard.
|
7
|
+
int numStudents = Integer.parseInt(keyboard.nextLine());
|
8
8
|
|
9
|
-
他にも色々ソースコード上の問題がありますが、IDE eclipseなどを入れてデバック実行して確認してみるのがいいと思います。
|
9
|
+
他にも色々ソースコード上の問題がありますが、IDE eclipseなどを入れてデバック実行して確認してみるのがいいと思います。
|
10
|
+
|
11
|
+
□参考情報
|
12
|
+
[Scanner#nextLine](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Scanner.html#nextLine--)
|