Skip to main content
added 188 characters in body
Source Link
alex2k8
  • 43.4k
  • 60
  • 173
  • 224

An other possible solution:

for(Object it : set.toArray()) { /* Create a copy */ Integer element = (Integer)it; if(element % 2 == 0) set.remove(element); } 

Or:

Integer[] copy = new Integer[set.size()]; set.toArray(copy); for(Integer element : copy) { if(element % 2 == 0) set.remove(element); } 

An other possible solution:

for(Object it : set.toArray()) { /* Create a copy */ Integer element = (Integer)it; if(element % 2 == 0) set.remove(element); } 

An other possible solution:

for(Object it : set.toArray()) { /* Create a copy */ Integer element = (Integer)it; if(element % 2 == 0) set.remove(element); } 

Or:

Integer[] copy = new Integer[set.size()]; set.toArray(copy); for(Integer element : copy) { if(element % 2 == 0) set.remove(element); } 
Source Link
alex2k8
  • 43.4k
  • 60
  • 173
  • 224

An other possible solution:

for(Object it : set.toArray()) { /* Create a copy */ Integer element = (Integer)it; if(element % 2 == 0) set.remove(element); }