Java Array Element Get getArrayNoNull(Object[] array)

Here you can find the source of getArrayNoNull(Object[] array)

Description

get Array No Null

License

Open Source License

Declaration

public static Object[] getArrayNoNull(Object[] array) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static Object[] getArrayNoNull(Object[] array) {
        if (array != null && array.length > 0) {
            List<Object> result = new ArrayList<>();

            for (Object obj : array) {
                if (!isNull(obj))
                    result.add(obj);//from   w w  w. j  av  a 2s  . c  om
            }

            return result.toArray();
        }

        return null;
    }

    public static boolean isNull(Object... objects) {
        boolean result = false;
        for (int i = 0; i < objects.length; i++) {
            if (objects[i] == null) {
                result = true;
                continue;
            }
        }
        return result;
    }
}

Related

  1. getAllMatches(String[] target, String[] pattern)
  2. getArgPairsSeparatedByChar(String[] args, String separator)
  3. getArgs(final String[] args, final String[] defaultValue, final String... flags)
  4. getArgs(String[] args, String... singleArgs)
  5. getArgsOption(String[] args, String option)
  6. getArrayPreview(final Object[] array, final int previewSize)
  7. getArrays(byte[] inputArray, int arraySize, boolean zeroPad)
  8. getArraySubset(T[] array, int start, int end)
  9. getFrequentElement(int[] bcp)