关于#java#的问题,请各位专家解答!(开发工具-eclipse)

提示用户“请输入你的年龄”,定义一个变量age接收用户的输入,然后用二路分支去判断,如果大于等于18,就输出“欢迎来到王者荣耀”,否则就输出“末成年,回去上学吧”


    public static void main(String[] args) {
        System.out.println("请输入你的年龄");
        while (true) {
            Scanner scanner = new Scanner(System.in);
            Integer next = null;
            try {
                next = scanner.nextInt();
                if (next >= 18) {
                    System.out.println("欢迎来到王者荣耀");
                } else if (next == 0) {
                    break;
                } else {
                    System.out.println("末成年,回去上学吧");
                }
            } catch (Exception e) {
                System.out.println("请输入你的年龄");
                continue;
            }
            try {

            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        System.out.println("已成功退出!");
    }

1、写一个扫描器scanner
2 、if()带入条件进行判断 就输出“欢迎来到王者荣耀” else 反之