Guest User

Untitled

a guest
Dec 10th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.56 KB | None | 0 0
  1. List<String> list = new ArrayList<String>;
  2.  
  3. public void myMethod(){
  4.         Iterator<String> it = list.iterator();
  5.         while (it.hasNext()) {
  6.         if (stringMethod(it.next())) {
  7.             it.remove();
  8.         }
  9.     }
  10. }
  11.  
  12. public boolean stringMethod(String s) {
  13.         final boolean shouldRemove = shouldRemove(s);
  14.     if (condition) {
  15.         for (String s1 : list) { //concurrentmodificationexception on this line
  16.             if (shouldRemove && s1 == s) {
  17.                 continue;
  18.             }
  19.             //do stuff
  20.         }
  21.     }
  22.         return shouldRemove;
  23. }
  24.  
  25. private boolean shouldRemove(String s) {
  26.     // do stuff
  27. }
Add Comment
Please, Sign In to add comment