方法详解
package commonTools;
import java.util.ArrayList;
import java.util.Collection;
public class CollectionUtils {
public static void main(String[] args) {
System.out.println("---------------集合1中的元素---------------");
Collection collection01 = new ArrayList();
collection01.add(2);
collection01.add(4);
collection01.add(6);
collection01.add(8);
collection01.add(10);
for (Object num : collection01) {
System.out.print(num + " ");
}
System.out.println("\n\n---------------集合2中的元素---------------");
Collection collection02 = new ArrayList();
collection02.add(1);
collection02.add(2);
collection02.add(3);
collection02.add(4);
collection02.add(5);
for (Object num : collection02) {
System.out.print(num + " ");
}
boolean flag =