50,535
社区成员
发帖
与我相关
我的任务
分享
Scanner scanner = new Scanner(System.in);
ArrayList<Integer> ns = new ArrayList<>();
do {
String string = scanner.nextLine();
if (string.equals("")) {
break;
}
ns.add(Integer.valueOf(string));
} while (true);
System.out.println(ns);
Scanner scanner = new Scanner(System.in);
ArrayList<Integer> nsArrayList = new ArrayList<>();
do {
String string = scanner.nextLine();
if (string.isEmpty()) {
break;
}
nsArrayList.add(Integer.valueOf(string));
} while (true);
ArrayList<String> array = new ArrayList<String>();
Scanner scn = new Scanner(System.in);
String line;
while (!"end".equals(line = scn.nextLine())) {
array.add(line);
}
for(String str : array){
System.out.println(str);
}