回答編集履歴
3
追記
test
CHANGED
@@ -14,9 +14,19 @@
|
|
14
14
|
|
15
15
|
System.out.println(Arrays.asList(array));
|
16
16
|
|
17
|
+
|
18
|
+
|
19
|
+
sc.close();
|
20
|
+
|
17
21
|
```
|
18
22
|
|
19
23
|
|
24
|
+
|
25
|
+
Scannerをインスタンス化する場合、最後にcloseしてあげるのを忘れないでください。
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
---
|
20
30
|
|
21
31
|
なお、こんな質問を見つけたのでご紹介しておきます。
|
22
32
|
|
@@ -27,3 +37,11 @@
|
|
27
37
|
Scanner is skipping nextLine() after using next(), nextInt() or other nextFoo()?
|
28
38
|
|
29
39
|
](https://stackoverflow.com/questions/13102045/scanner-is-skipping-nextline-after-using-next-nextint-or-other-nextfoo)
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
nextで上手くいく理由
|
44
|
+
|
45
|
+
---
|
46
|
+
|
47
|
+
[Scanner#next](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Scanner.html#next--)は、**有効なトークン**を読み込んでくれるようです。
|
2
成形
test
CHANGED
@@ -22,6 +22,8 @@
|
|
22
22
|
|
23
23
|
こちらでは、また別の解法も回答されています。
|
24
24
|
|
25
|
+
[StackOverflow
|
26
|
+
|
25
|
-
|
27
|
+
Scanner is skipping nextLine() after using next(), nextInt() or other nextFoo()?
|
26
28
|
|
27
29
|
](https://stackoverflow.com/questions/13102045/scanner-is-skipping-nextline-after-using-next-nextint-or-other-nextfoo)
|
1
追記
test
CHANGED
@@ -15,3 +15,13 @@
|
|
15
15
|
System.out.println(Arrays.asList(array));
|
16
16
|
|
17
17
|
```
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
なお、こんな質問を見つけたのでご紹介しておきます。
|
22
|
+
|
23
|
+
こちらでは、また別の解法も回答されています。
|
24
|
+
|
25
|
+
[StackOverflow - Scanner is skipping nextLine() after using next(), nextInt() or other nextFoo()?
|
26
|
+
|
27
|
+
](https://stackoverflow.com/questions/13102045/scanner-is-skipping-nextline-after-using-next-nextint-or-other-nextfoo)
|