自己写了个containsAll方法的使用,仅供参考
public void testContainsAll() {
System.out.println("一共查询多少门课程?");
int num = scanner.nextInt();
List<Courses> queryName = new ArrayList<Courses>();
for(int i=0; i<num; i++) {
System.out.println("请输入查询的课程"+(i+1)+"名称:");
String inputName = scanner.next();
Courses c = new Courses();
c.name = inputName;
queryName.add(c);
}
System.out.print("查询的课程:");
for (Courses courses : queryName) {
System.out.print(courses.name+" ");
}
System.out.println("\n备选课程中是否包含课程:"+coursesToSelect.containsAll(queryName));
}