我正在努力寻找相关的答案来解决我的问题。我有一个数组列表:
List<Teacher> teacherList = new ArrayList<Teacher>(11);
教师类有一个 name 属性。我想扫描教师列表,并找出是否有与用户输入的名称匹配的名称。
例如,
Scanner teacherNameScanner = new Scanner (System.in);
System.out.println("What is the teachers name");
teacherName = teacherNameScanner.nextLine();
/* Here I want to scan through the teacherList and see whether the name entered
matches the name of any of the teachers. If it does not match I want to tell the
user to enter a correct name */
海绵宝宝撒
慕容森
慕桂英4014372
相关分类