Here you can find the source of removeNulls(T[] array)
public static <T> T[] removeNulls(T[] array)
//package com.java2s; // are made available under the terms of the Eclipse Public License v1.0 import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class Main { public static <T> T[] removeNulls(T[] array) { for (T t : array) { if (t == null) { List<T> list = new ArrayList<>(); for (T t2 : array) if (t2 != null) list.add(t2);/* www . ja v a 2s. c o m*/ return list.toArray(Arrays.copyOf(array, list.size())); } } return array; } }