Java Array Empty Check isEmpty(Object[] array)

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

Description

This method returns true if the input array is null or its length is zero.

License

Open Source License

Parameter

Parameter Description
array a parameter

Return

true | false

Declaration

public static boolean isEmpty(Object[] array) 

Method Source Code


//package com.java2s;
import java.util.Collection;
import java.util.Map;

public class Main {
    /**//from  w  w w .  j  a v  a 2 s .c om
     * This method returns true if the collection is null or is empty.
     * 
     * @param collection
     * @return true | false
     */
    public static boolean isEmpty(Collection<?> collection) {
        if (collection == null || collection.isEmpty()) {
            return true;
        }
        return false;
    }

    /**
     * This method returns true of the map is null or is empty.
     * 
     * @param map
     * @return true | false
     */
    public static boolean isEmpty(Map<?, ?> map) {
        if (map == null || map.isEmpty()) {
            return true;
        }
        return false;
    }

    /**
     * This method returns true if the input array is null or its length is
     * zero.
     * 
     * @param array
     * @return true | false
     */
    public static boolean isEmpty(Object[] array) {
        if (array == null || array.length == 0) {
            return true;
        }
        return false;
    }
}

Related

  1. isEmpty(Object[] args)
  2. isEmpty(Object[] arr)
  3. isEmpty(Object[] array)
  4. isEmpty(Object[] array)
  5. isEmpty(Object[] array)
  6. isEmpty(Object[] array)
  7. isEmpty(Object[] array)
  8. isEmpty(Object[] array)
  9. isEmpty(Object[] array)