1 /**从列表中移除指定 collection 中包含的所有元素。
2 *
3 */
4 @Test
5 public void test04(){
6 List<String>mother = new ArrayList<String>();
7 mother.add("准备拍摄"); //向列表中添加数据
8 mother.add("开始脱衣"); //向列表中添加数据
9 mother.add("开始啪啪"); //向列表中添加数据
10 List<String>son = new ArrayList<String>();
11 son.add("准备拍摄"); //向列表中添加数据
12 son.add("开始脱衣"); //向列表中添加数据
13 boolean ret = mother.removeAll(son); //从list中移除与list1相同的元素
14 Iterator<String> it = mother.iterator(); //创建迭代器
15 while(it.hasNext()){ //循环遍历迭代器
16 System.out.println(it.next()); //输出集合中元素
17 }
18 }