去掉List中所有null 元素

来源:互联网 发布:mq2烟雾传感器数据手册 编辑:程序博客网 时间:2024/06/10 19:40

1. 参考http://blog.csdn.net/zjh1n795/article/details/7550008:

Collection nuCon = new Vector(); 

nuCon.add(null); 

list.removeAll(nuCon);


2. 参考: http://stackoverflow.com/questions/1239579/helper-in-order-to-remove-null-reference-in-java-list

list.removeAll(Collections.singleton(null));

1 0
原创粉丝点击