Collecting
package Demo04;
import java.util.ArrayList;
import java.util.Collection;
public class Demo01Collection {
public static void main(String[] args) {
Collection<String> coll=new ArrayList<>();
System.out.println(coll);
boolean b1= coll.add("刘二狗");
System.out.println("b1: "+b1);
System.out.println(coll);
coll.add("老村长");
coll.add("廖境泽");
coll.add("江户川二狗");
System.out.println(coll);
boolean b2=coll.remove("lcz");
boolean b3=coll.remove("老村长");
System.out.println("b2: "+b2);
System.out.println("b3: "+b3);
System.out.println(coll);
boolean b4=coll.contains("lcz");
boolean b5=coll.contains("刘二狗");
System.out.println("b4: "+b4);
System.out.println("b5: "+b5);
boolean b6=coll.isEmpty();
System.out.println("b6: "+b6);
int size=coll.size();
System.out.println("size:"+size);
Object[] arr=coll.toArray();
for (int i = 0; i < coll.size(); i++) {
System.out.println(arr[i]);
}
coll.clear();
System.out.println(coll);
}
}