Here you can find the source of removeNulls(List
Parameter | Description |
---|---|
T | the type of the parameter list and the resulting list |
values | the list to be processed |
public static <T> List<T> removeNulls(List<T> values)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.List; public class Main { /**//from w ww. j a va 2 s . c om * Creates a new list which contains all the non-null elements of the given list. * @param <T> the type of the parameter list and the resulting list * @param values the list to be processed * @return the same values except nulls */ public static <T> List<T> removeNulls(List<T> values) { List<T> result = new ArrayList<>(); for (T value : values) { if (value != null) { result.add(value); } } return result; } }