List.remove(Object o)
:刪除一個元素,成功則返回true
;需要注意它只刪除一個;List.removeAll(Collection<?> c)
:刪除存在集合c的所有情況,注意入參不是一個元素;List.removeIf(Predicate<? super E> filter)
:刪除所有滿足條件的元素,入參爲Lambda表達式。
例如:list.removeAll(Collections.singletonList(null));
Stream方法
List<String> result = list.parallelStream() .filter(Objects::nonNull) .collect(Collectors.toList());