📜  java 扫描器字符串到 int - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:31.505000             🧑  作者: Mango

代码示例1
Scanner scanner = new Scanner(System.in);
    while (true) {
        String input = scanner.next();
            try {
                int a = Integer.parseInt(input);
                if (a == 0) {
                    break;
                }
                System.out.println(Integer.parseInt(input) * 10);
            } catch (NumberFormatException e) {
                System.out.println("Invalid user input: " + input);
            }
        }