Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- employeeList1 // data present
- employeeList2 // data present
- ListIterator<Employee> zeroList=employeeList2.listIterator();
- //remove employee if already present in list1
- while(zeroList.hasNext()){
- for(Employee employee : employeeList1){
- if(zeroList.next().getID().equals(employee.getId())){
- zeroList.remove();
- }
- }
- }
- java.util.NoSuchElementException
- List<String> list1 = new ArrayList<>();
- list1.add("a");
- list1.add("b");
- list1.add("c");
- List<String> list2 = new ArrayList<>();
- list2.add("a");
- list2.add("p");
- list2.add("q");
- list2.removeAll(list1);
- System.out.println(list2);
- [p, q]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement