在执行循环嵌套时,出现重复现象

源代码:
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
ArrayList array = new ArrayList();
Teacher teacher=new Teacher();
ArrayListarr=new ArrayList() ;
Student student = new Student();//实例化对象
boolean a=true,a1=true;

    System.out.println("=============欢迎使用疫情的打卡后台管理系统=============");
    while (true) {

        System.out.println("请选择:1.老师打卡管理 2.学生打卡管理 0.退出系统");
       // String temp=sc.nextLine();
       // boolean flag=temp.matches("[0-9]+");
        int line=sc.nextInt();
        if (line==0||line==1||line==2){

         //   int line=Integer.parseInt(temp);
            switch (line) {

                case 1:
                    while (a1) {
                        System.out.println("请选择:1.录入打卡信息 2.删除打卡信息 3.查询打卡信息 4.返回上级菜单");
                        int jieshou = sc.nextInt();
                        switch (jieshou) {
                            case 1:
                                teacher.addTeacher(arr);
                                break;
                            case 2:
                                teacher.deleteTeacher(arr);
                                break;
                            case 3:
                                teacher.updateTeacher(arr);
                                break;
                            case 4:
                                a1=false;
                                break;
                        }
                    }continue;

                case 2:

                    while (a) {
                        System.out.println("请选择:1.录入打卡信息 2.删除打卡信息 3.查询打卡信息 4.返回上级菜单");
                        int jieshou1 = sc.nextInt();
                        switch (jieshou1) {
                            case 1:
                                student.addStudent(array);
                                break;
                            case 2:
                                student.deleteStudent(array);
                                break;
                            case 3:
                                student.updateStudent(array);
                                break;
                            case 4:
                                a=false;
                                break;
                        }
                    }continue;

                case 0:
                    System.out.println("您已退出疫情打卡管理系统,欢迎再次使用!");
                    System.exit(0);//JVM退出
            }
        }else {
            System.out.println("您的输入有误,请重新输入!");
        }
        }

    }
}

boolean a=true,a1=true;
这两个要写在外侧while的里面,否则一旦退出菜单就进不去了。