Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<String> list = new ArrayList<String>;
- public void myMethod(){
- Iterator<String> it = list.iterator();
- while (it.hasNext()) {
- if (stringMethod(it.next())) {
- it.remove();
- }
- }
- }
- public boolean stringMethod(String s) {
- final boolean shouldRemove = shouldRemove(s);
- if (condition) {
- for (String s1 : list) { //concurrentmodificationexception on this line
- if (shouldRemove && s1 == s) {
- continue;
- }
- //do stuff
- }
- }
- return shouldRemove;
- }
- private boolean shouldRemove(String s) {
- // do stuff
- }
Add Comment
Please, Sign In to add comment