Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. List<String> strList = new ArrayList<>();
  2. strList.add("Anna");
  3. strList.add("Ada");
  4. strList.add("Bob");
  5. strList.add("Bob");
  6.  
  7. List<String> removeList = new ArrayList<>();
  8. removeList.add("Bob");
  9. strList.removeAll(removeList);
  10.  
  11. for (int i = strList.size() - 1; i > 0; i--) {
  12. if(strList.get(i).equals("Bob")) strList.remove(i);
  13. }
  14.  
  15. System.out.println(strList);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement