我希望 ID 是 1,2,3,4 每个新名称,即
ID - 姓名 - 年龄
1 - 保罗 - 60
2 - 里吉斯 - 25
3 - 安娜 - 20
自动识别
static void register(ArrayList mylist) {
int i = 1;
Scanner in = new Scanner(System.in);
Peoples p = new Peoples();
// System.out.print("ID: ");
// p.ID = in.nextInt();
p.ID = i;
i++;
in.nextLine();
System.out.print("Name: ");
p.name = in.nextLine();
System.out.print("Age: ");
p.age = in.nextInt();
mylist.add(p);
}
public class Peoples {
public int ID;
public String name;
public int age;
}