该列表无法从另一个列表中删除数据

时间:2019-04-07 17:16:51

标签: java list

我要删除另一个列表中存在的列表元素

代码

List<Courses> fav = new ArrayList<Courses>();
List<Courses> course = courseDaoImpl.listCoures();
LOGGER.log(Level.INFO, "Intial Course list"+course.toString());
List<String> favcourse = userData1.getCourses();
LOGGER.log(Level.INFO, "userFavCourse"+favcourse.toString());
Iterator<String> itr = favcourse.iterator();
while(itr.hasNext()) {
    fav.add(courseDaoImpl.findOne(itr.next()));
}
LOGGER.log(Level.INFO, "favcoursevalue\n"+fav.toString());
course.removeAll(fav);
LOGGER.log(Level.INFO, "Final course list\n"+course.toString());        

输出日志

INFO: Intial Course list[Courses [id=5c8be342860a164928b057ae, courseName=The great anand, author=idk, content=This is the best book so far, imageUrl=https://udemy-images.udemy.com/course/240x135/567828_67d0.jpg, favoriteCourse=null], Courses [id=5ca7965ef1649446e4c0f173, courseName=Spring and hiberante, author=coolguy, content=Spring 5: Learn Spring 5 Core, AOP, Spring MVC, Spring Security, Spring REST, Spring Boot 2, Thymeleaf, JPA & Hibernate, imageUrl=https://i.udemycdn.com/course/240x135/647428_be28_6.jpg, favoriteCourse=null], Courses [id=5ca7b503f1649446e4c0f174, courseName=javaTutorials, author=the great me, content=null, imageUrl=https://i.udemycdn.com/course/240x135/24823_963e_14.jpg, favoriteCourse=null], Courses [id=5ca7b567f1649446e4c0f175, courseName=Microsoft Excel, author=Kyle Pew, content=Excel with this A-Z Microsoft Excel Course. Microsoft Excel 2010, Excel 2013, Excel 2016, imageUrl=https://i.udemycdn.com/course/240x135/793796_0e89.jpg, favoriteCourse=null]]
INFO: userFavCourse[Spring and hiberante]
INFO: favcoursevalue
[Courses [id=5ca7965ef1649446e4c0f173, courseName=Spring and hiberante, author=coolguy, content=Spring 5: Learn Spring 5 Core, AOP, Spring MVC, Spring Security, Spring REST, Spring Boot 2, Thymeleaf, JPA & Hibernate, imageUrl=https://i.udemycdn.com/course/240x135/647428_be28_6.jpg, favoriteCourse=null]]
Apr 07, 2019 10:41:59 PM com.in28minutes.home.HomeController getRecommendation
INFO: Final course list
[Courses [id=5c8be342860a164928b057ae, courseName=The great anand, author=idk, content=This is the best book so far, imageUrl=https://udemy-images.udemy.com/course/240x135/567828_67d0.jpg, favoriteCourse=null], Courses [id=5ca7965ef1649446e4c0f173, courseName=Spring and hiberante, author=coolguy, content=Spring 5: Learn Spring 5 Core, AOP, Spring MVC, Spring Security, Spring REST, Spring Boot 2, Thymeleaf, JPA & Hibernate, imageUrl=https://i.udemycdn.com/course/240x135/647428_be28_6.jpg, favoriteCourse=null], Courses [id=5ca7b503f1649446e4c0f174, courseName=javaTutorials, author=the great me, content=null, imageUrl=https://i.udemycdn.com/course/240x135/24823_963e_14.jpg, favoriteCourse=null], Courses [id=5ca7b567f1649446e4c0f175, courseName=Microsoft Excel, author=Kyle Pew, content=Excel with this A-Z Microsoft Excel Course. Microsoft Excel 2010, Excel 2013, Excel 2016, imageUrl=https://i.udemycdn.com/course/240x135/793796_0e89.jpg, favoriteCourse=null]]

我希望删除带有弹簧名称的课程

0 个答案:

没有答案