package com.day15.collection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
public class CollectionIterator {
public static void main(String[] args) {
Collection c=new ArrayList();
c.add("a");
c.add("b");
c.add("c");
c.add( "d");
Iterator it =c.iterator();//Get the iterator
/* boolean b1=it.hasNext();//Determine whether there is an element in the collection, return true if there is
Object obj1=it.next( );
System.out.println(b1);//true
System.out.println(obj1);//a
boolean b2=it.hasNext();//To judge whether there is an element in the collection, return true if there is
Object obj2 =it.next();
System.out.println(b2);//true
System.out.println(obj2);//b
*/ /*while(it.hasNext()) {
System.out.println( it.next());
}*/
Collection c1=new HashSet();
c1.add("a");
c1.add("f");
c.removeAll(c1);
System.out.println(c.toString());//[b, c, d] delete the intersection of two objects, because the implementation of the collection interface The class AbstractList overrides the toString() method, and the ArrayList class inherits the AbstractList class
}
}