首页 > 解决方案 > 试图避免为 I/O 按两次 Enter

问题描述

我无法通过按一次输入来输入整数,而不是两次。

我也尝试在第二行之后使用 scan.nextLine() 。

    Scanner scan = new Scanner(System.in);
    int choice = Integer.parseInt(scan.nextLine());
    scan.close();
    System.out.println(choice);

标签: java

解决方案


推荐阅读