Java Array Remove removeNulls(T[] array)

Here you can find the source of removeNulls(T[] array)

Description

remove Nulls

License

Open Source License

Declaration

public static <T> T[] removeNulls(T[] array) 

Method Source Code

//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;
    }
}

Related

  1. removeNodes(T[] array, T sampleNode)
  2. removeNull(T[] data)
  3. removeNullElements(String[] x)
  4. removeNulls(Object[] arr)
  5. removeNulls(T[] array)
  6. removeNulls(T[] input)
  7. removeNullsFromStringArray(String[] array)
  8. removeOwnCookieNameFromCookieHeader(String ownCookieName, String[] cookies)
  9. removePointerFromDesc(String[] desc)