【发布时间】:2018-08-04 04:25:21
【问题描述】:
例如,我如何取值1 0 或仅取值2 然后在程序的后半部分使用。假设1 将数字0 添加到列表中,2 打印出一个短语。现在我只知道如何在同一行使用两个数字
Scanner sc = new Scanner(System.in); // receives input for x y
int x = Integer.parseInt(sc.next());
int y = Integer.parseInt(sc.next());
【问题讨论】:
-
和don't need to say that it is in Java in the title - 使用java 标记系统会自动执行此操作。
-
String line = sc.nextLine(); // <-- takes either one or two or three or none; however many are on one line.
标签: java input io java.util.scanner