我正在尝试使用for循环获取集合中的输入,但不知何故输出显示第0个位置为空
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
ArrayList<String> b = new ArrayList<String>();
String abc;
for (int i = a; i > 0; i--) {
abc = sc.nextLine();
b.add(abc);
}
我预计输出结果为:
[a, d, b, c, e]
但实际输出是:
[, a, d, b, c]
https://stackoverflow.com/questions/56174674
复制相似问题