-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAggregate.java
More file actions
35 lines (32 loc) · 1.48 KB
/
Copy pathAggregate.java
File metadata and controls
35 lines (32 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package ThreadTest;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
public class Aggregate {
public void test(){
Collection collection = new ArrayList();
collection.add("孙悟空");
collection.add(6);
System.out.println("collection元素的集合个数为"+collection.size());
collection.remove(6);
System.out.println("collection元素的集合个数为"+collection.size());
System.out.println("collection的集合里面是否包含孙悟空的元素"+collection.contains("孙悟空"));
collection.add("hanshizhe");
collection.add(990);
collection.add("疯狂JAVA讲义");
// collection.add("疯狂ANDROID讲义");
System.out.println("collection所有集合数为"+collection);
Collection books = new HashSet();
books.add("疯狂JAVA讲义");
books.add("疯狂ANDROID讲义");
System.out.println("books所有集合数为"+books);
System.out.println("collection集合是否包含所有books集合"+collection.containsAll(books));
System.out.println("collection所有集合数为"+collection);
// collection.removeAll(books);
System.out.println("collection 去掉BOOKS的集合为"+collection);
// collection.clear();
System.out.println("删除collection所有集合数为"+collection);
// books.retainAll(collection);
System.out.println("books所有集合数为"+books);
}
}