JAVA在迭代器中删除元素

需要先显示的声明一下迭代器

Iterator it=list.iterator();
 
        while(it.hasNext()){
            Object e=it.next();
            if("b".equals(e)){
                it.remove();
            }
        }
        System.out.println(list);

猜你喜欢

转载自blog.csdn.net/qq_41359808/article/details/88759387