Guest User

Untitled

a guest
Jun 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. List predicatedList = ListUtils.predicatedList(new ArrayList(), PredicateUtils.notNullPredicate());
  2. ...
  3. predicatedList.add(null); // throws an IllegalArgumentException
  4.  
  5. try
  6. {
  7. predicatedList.add(null);
  8. }
  9. catch(IllegalArgumentException e)
  10. {
  11. //ignore the exception
  12. }
  13.  
  14. List l = new ArrayList();
  15. l.add("A");
  16. l.add(null);
  17. l.add("B");
  18. l.add(null);
  19. l.add("C");
  20.  
  21. System.out.println(l); // Outputs [A, null, B, null, C]
  22.  
  23. CollectionUtils.filter(l, PredicateUtils.notNullPredicate());
  24.  
  25. System.out.println(l); // Outputs [A, B, C]
Add Comment
Please, Sign In to add comment