JAVA List中剔除空元素(null)的方法

方法一、list.removeAll(Collections.singleton(null));

      方法二、List nullList = new ArrayList();
                 nullList.add(null);
                 list.removeAll(nullList);

   方法三、

         Iterator it = list.iterator();
        while (it.hasNext()) {
       if (it.next() == null) {
        it.remove();
    }
}

原文地址:https://www.cnblogs.com/zouhong/p/9504258.html