Java Array Empty Check isEmpty(final Object[] array)

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

Description

Is the given array null or empty ?

License

Open Source License

Parameter

Parameter Description
array array to test

Return

true if the array is null or empty

Declaration

public static boolean isEmpty(final Object[] array) 

Method Source Code


//package com.java2s;

import java.util.Collection;

import java.util.Map;

public class Main {
    /**/*www. ja v  a  2  s . c o m*/
     * Is the given map null or empty ?
     *
     * @param map map to test
     * @return true if the map is null or empty
     */
    public static boolean isEmpty(final Map<?, ?> map) {
        return map == null || map.isEmpty();
    }

    /**
     * Is the given collection null or empty ?
     *
     * @param col collection to test
     * @return true if the collection is null or empty
     */
    public static boolean isEmpty(final Collection<?> col) {
        return col == null || col.isEmpty();
    }

    /**
     * Is the given array null or empty ?
     *
     * @param array array to test
     * @return true if the array is null or empty
     */
    public static boolean isEmpty(final Object[] array) {
        return array == null || array.length == 0;
    }
}

Related

  1. hasOneEmpty(String[] args)
  2. isEmpty(boolean[] values)
  3. isEmpty(byte[] array)
  4. isEmpty(E[] array)
  5. isEmpty(final int[] arr)
  6. isEmpty(final X[] array)
  7. isEmpty(int[] array)
  8. isEmpty(int[] array)
  9. isEmpty(Object[] args)