Java While Loop for ArrayList无法获取数组中的数据

我正在尝试使用菜单循环,而不是在完成第一个选择时想要在选择2中获取数据。 无法获取,这是一个错误。

线程“主”中的异常java.lang.IndexOutOfBoundsException:索引0超出长度0         在java.base / jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)         在java.base / jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)         在java.base / jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)         在java.base / java.util.Objects.checkIndex(Objects.java:373)         在java.base / java.util.ArrayList.get(ArrayList.java:425)         在craitid_19.main(craitid-19.java:38)

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
class craitid_19{
    public static void main(String [] args){
        while(true){
        System.out.println("1 - Insert");
        System.out.println("2 - Edit");
        System.out.println("3 - View");
        System.out.println("4 - Exit");
        Scanner input = new Scanner(System.in);
        int choice = input.nextInt();
        infected patient = new infected();

        switch (choice){
        case 1: 
            System.out.print("ID = ");
            int id = input.nextInt();
            System.out.print("name = ");
            String name = input.next();
            System.out.print("age = ");
            String age = input.next();
            System.out.print("gender = ");
            String gender = input.next();
            System.out.print("date = ");
            String date = input.next();
            System.out.print("province = ");
            String province = input.next();
            System.out.print("infectby = ");
            String infectby = input.next();
            patient.children.add(new normal(id, name, age, gender, date, province, infectby));
            System.out.print(patient.toString());
            continue;


        case 2:
            System.out.println("Insert ID");
            System.out.print(patient.children.get(0));

        case 4:
            System.out.println("Exiting Program...");
            System.exit(0);
            break;
        default :
             System.out.println("This is not a valid Menu Option! Please Select Another");
             break;
        }
        }
    }
}
class infected {    
    public int id;
    public String name;
    public String age;
    public String gender;
    public String date;
    public String province;
    public String infectby;
    public String type;

    public List<infected> children = new ArrayList<>();

    public infected(){
    }

    @Override
    public String toString()
    {
    String returnString = id + (",") + name + (",") + age + (",") + gender + (",") + date + (",") + province + (",") + infectby + (",") + type + System.lineSeparator();
    for (infected child : children) 
    returnString = child.toString() + System.lineSeparator();
    return returnString;
    }
}

class normal extends infected{
    public normal(int id, String name, String age, String gender, String date, String province, String infectby){
        type = "1";
        this.id = id;
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.date = date;
        this.province = province;
        this.infectby = infectby;

    }


}