Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Java ArrayList concurrent modification
- for(Iterator<Object> i = mylist.iterator(); i.hasNext();) {
- Object obj = i.next();
- ArrayList<Object> newlist = new ArrayList<Object>();
- newlist.add(obj);
- i.remove();
- for(Iterator<Object> in = mylist.iterator(); in.hasNext();) {
- Object next = in.next();
- if (obj != next && (another condition)) {
- newlist.add(next);
- in.remove();
- }
- }
- if (newlist.size() > 2) anotheList.add(newlist);
- else for(Object r : newlist) {
- //mylist get back object:
- mylist.add(r);
- }
- }
- while (!myList.isEmpty()) {
- Object obj = myList.remove(0);
- ...
- }
Add Comment
Please, Sign In to add comment