teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

era

2021/07/03 14:03

投稿

square
square

スコア5

title CHANGED
@@ -1,1 +1,1 @@
1
- arraylist addの使い方【JAVA】
1
+ erarraylist addの使い方【JAVA】
body CHANGED
@@ -36,4 +36,11 @@
36
36
  }
37
37
  ```
38
38
 
39
+ エラー;
39
- エラー;Exception in thread "main" java.lang.IndexOutOfBoundsException: Index 5 out of bounds for length
40
+ Exception in thread "main" java.lang.IndexOutOfBoundsException: Index 5 out of bounds for length 5
41
+ at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
42
+ at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
43
+ at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
44
+ at java.base/java.util.Objects.checkIndex(Objects.java:359)
45
+ at java.base/java.util.ArrayList.get(ArrayList.java:427)
46
+ at Main.main(Main.java:50)

1

sc al

2021/07/03 14:03

投稿

square
square

スコア5

title CHANGED
File without changes
body CHANGED
@@ -1,6 +1,8 @@
1
1
  リストに入れたものを繰り返し取り出したいのですが、エラーになってしまいます。
2
2
 
3
3
  ```JAVA
4
+ Scanner sc = new Scanner(System.in);
5
+ List<Double> al = new ArrayList<Double>();
4
6
  int b = -1;
5
7
  for(int j = 0; j < camera; j++) {
6
8
  x = sc.nextDouble();