daily pastebin goal
90%
SHARE
TWEET

Untitled

a guest Dec 10th, 2018 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top