@Test
    public void testRemove(){
        Collection<String> c = new HashSet<String>();
        c.add("java");
        c.add("php");
        c.add("cpp");
        c.add("c#");
        Iterator<String> it = c.iterator();
        while(it.hasNext()){
            String str = it.next();
            if(str.indexOf('c')!=-1){
                it.remove();
            }
        }
        System.out.println(c);
    }
}

 

posted on 2017-06-01 20:30  两枝梅  阅读(1920)  评论(0编辑  收藏  举报