Java Array Empty Check isEmpty(Object[] array)

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

Description

isEmpty Test to see whether input string is empty.

License

Open Source License

Parameter

Parameter Description
str A String

Return

True if it is empty; false if it is not.

Declaration

public static boolean isEmpty(Object[] array) 

Method Source Code

//package com.java2s;
/*/*w  ww .  j a v a  2 s. c o m*/
* @(#)Utility.java
*
* Copyright (c) 2003 DCIVision Ltd
* All rights reserved.
*
* This software is the confidential and proprietary information of DCIVision
* Ltd ("Confidential Information").  You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the license
* agreement you entered into with DCIVision Ltd.
 */

public class Main {
    /**
     * isEmpty
     *
     * Test to see whether input string is empty.
     *
     * @param   str A String
     * @return  True if it is empty; false if it is not.
     */
    public static boolean isEmpty(String str) {
        return (str == null || str.length() == 0 || str.trim().equals(""));
    }

    /**
     * isEmpty
     *
     * Test to see whether input string buffer is empty.
     *
     * @param   str A StringBuffer
     * @return  True if it is empty; false if it is not.
     */
    public static boolean isEmpty(StringBuffer stringBuffer) {
        return (stringBuffer == null || stringBuffer.length() == 0 || stringBuffer.toString().trim().equals(""));
    }

    /**
     * isEmpty
     *
     * Test to see whether input string is empty.
     *
     * @param   str A String
     * @return  True if it is empty; false if it is not.
     */
    public static boolean isEmpty(Object[] array) {
        return (array == null || array.length == 0);
    }

    /**
     * isEmpty
     *
     * Test to see whether input is empty.
     *
     * @param   StringArray A array
     * @return  True if it is empty; false if it is not.
     */
    public static boolean isEmpty(String[] array) {
        return (array == null || array.length == 0);
    }

    /**
     * isEmpty
     *
     * Test to see whether input is representing a NULL value.
     *
     * @param   val An Object
     * @return  True if it represents NULL; false if it is not.
     */
    public static boolean isEmpty(Object val) {
        return (val == null);
    }

    /**
     * isEmpty
     *
     * Test to see whether input is empty.
     *
     * @param   list A List
     * @return  True if it is empty; false if it is not.
     */
    public static boolean isEmpty(java.util.List list) {
        return (list == null || list.size() == 0);
    }
}

Related

  1. isEmpty(Object[] array)
  2. isEmpty(Object[] array)
  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)