//集合增删查改
import java.util.*;
public class CollectionDemo {
public void testCol(){
Collection col=new ArrayList();
//add
col.add(1);
col.add(4);
col.add(4);
col.add(2);
col.add(3);
// enum
Iterator it=col.iterator();
while(it.hasNext()){
int a=(Integer)it.next();
System.out.println("hashsetValue="+a);
}
// delete
col.remove(3);
col.remove(4);
it=col.iterator();
while(it.hasNext()){
int b=(Integer)it.next();
System.out.println("remove "+b);
}
// update
Object[] arr=col.toArray();
col.clear();
for(int j=0; j<arr.length; j++){
if(arr[j].equals(4)){
arr[j]=(Integer)10010;
}
col.add(arr[j]);
}
it=col.iterator();
while(it.hasNext()){
int a=(Integer)it.next();
System.out.println("update= "+a);
}
}
public static void main(String[] args){
CollectionDemo coll=new CollectionDemo();
coll.testCol();
}
}