package com.itheima;
import java.util.*;
public class Test01
{
public static void main(String[] args)
{
ArrayList<String> aList=new ArrayList<String>();
aList.add("dsafsr");
aList.add("abc");
aList.add("fof");
aList.add("abcder");
System.out.println(aList.toString());
ArrayList<String> delList=new ArrayList<String>();
Iterator<String> it=aList.iterator();
while(it.hasNext())
{
String s=it.next();
if(s.equals("abc"));
delList.add(s);
}
aList.removeAll(delList);
System.out.println(aList.toString());
}
}
打印结果:
[dsafsr, abc, fof, abcder]
[]
只想删除“abc”,但全被删除了。。。
|
|