import
java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Main {
public static void print( List < Integer > list) {
Iterator < Integer > itr = list . iterator();
while ( itr . hasNext()) {
System . out . print( itr . next());
System . out . print( ", ");
}
System . out . println();
}
public static void main( String [] args) {
List < Integer > s = new ArrayList < Integer >();
for ( Integer i = 0; i < 10; i ++) {
s . add( i);
}
print(s);
Iterator < Integer > itr = s . iterator();
while ( itr . hasNext()) {
Integer i = itr . next();
if ( i % 3 == 0) {
itr . remove();
}
}
/**
* 错误
*/
// for(Integer i: s){
// if (i % 3 == 0) {
// s.remove(i);
// }
// }
print(s);
}
}
import java.util.Iterator;
import java.util.List;
public class Main {
public static void print( List < Integer > list) {
Iterator < Integer > itr = list . iterator();
while ( itr . hasNext()) {
System . out . print( itr . next());
System . out . print( ", ");
}
System . out . println();
}
public static void main( String [] args) {
List < Integer > s = new ArrayList < Integer >();
for ( Integer i = 0; i < 10; i ++) {
s . add( i);
}
print(s);
Iterator < Integer > itr = s . iterator();
while ( itr . hasNext()) {
Integer i = itr . next();
if ( i % 3 == 0) {
itr . remove();
}
}
/**
* 错误
*/
// for(Integer i: s){
// if (i % 3 == 0) {
// s.remove(i);
// }
// }
print(s);
}
}