删除集合某元素,避免空指针

1、使用原始for循环

for(int i =0 ; i

2、使用迭代器(官方推荐)

Iterator it = intList.iterator();
where(it.hasNext()){
    if(it.next() == 13){   //it.next()方法即可返回当前元素
        it.remove();
    }

转载于:https://www.cnblogs.com/CatcherLJ/p/11314493.html

你可能感兴趣的:(数据库)