java - 试图避免为 I/O 按两次 Enter
问题描述
我无法通过按一次输入来输入整数,而不是两次。
我也尝试在第二行之后使用 scan.nextLine() 。
Scanner scan = new Scanner(System.in);
int choice = Integer.parseInt(scan.nextLine());
scan.close();
System.out.println(choice);
解决方案
推荐阅读
- python - 单个单词具有多个类别特征的词嵌入
- c# - Graph-API /v1.0/Teams/id 被阻止
- angular - 如何应用文本装饰:单击角度复选框时的行彻底
- halide - Halide 如何应用区间分析?
- r - R:计算组子集的 RMS
- python - 在 Robot Framework 中导入自定义测试库
- ios - Swift:在另一个目标中使用协议找不到某些属性
- python - 将图像分成块并比较每个对应的块
- python - 用 pybind11 包装 C++ 分配的实例
- type-conversion - 当 std_logic_vector 的大小可参数化时,如何计算它所需的位数?