public class Solution {
// instance variables
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int T = scan.nextInt();
int[] arr = new int[T];
int arr[T-1] = s.nextInt();
while(T-->0) {
arr[T] = s.nextInt(); // Exception comes here
}
}
}
我在异常日志转储下面得到此信息
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:907)
at java.util.Scanner.next(Scanner.java:1530)
at java.util.Scanner.nextInt(Scanner.java:2160)
at java.util.Scanner.nextInt(Scanner.java:2119)
at Solution.main(Solution.java:6)
我正在弹出堆栈并将其结果保存在某些用例的数组中,然后遇到了NoSuchElementException。我写了一个等效的代码作为参考。什么是元素...