Java Array Empty Check isEmpty(Object[] array)

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

Description

Check if the array supplied is empty.

License

Apache License

Parameter

Parameter Description
array The array to check

Return

true if the array supplied is empty

Declaration

public static boolean isEmpty(Object[] array) 

Method Source Code


//package com.java2s;
/*! ******************************************************************************
 *
 * Pentaho Data Integration/* w  ww . j  a  v a 2s .c om*/
 *
 * Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com
 *
 *******************************************************************************
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 ******************************************************************************/

import java.util.List;

public class Main {
    /**
     * Check if the CharSequence supplied is empty. A CharSequence is empty when it is null or when the length is 0
     *
     * @param val
     *          The stringBuffer to check
     * @return true if the stringBuffer supplied is empty
     */
    public static boolean isEmpty(CharSequence val) {
        return val == null || val.length() == 0;
    }

    /**
     * Check if the CharSequence array supplied is empty. A CharSequence array is empty when it is null or when the number of elements
     * is 0
     *
     * @param strings
     *          The string array to check
     * @return true if the string array supplied is empty
     */
    public static boolean isEmpty(CharSequence[] strings) {
        return strings == null || strings.length == 0;
    }

    /**
     * Check if the array supplied is empty. An array is empty when it is null or when the length is 0
     *
     * @param array
     *          The array to check
     * @return true if the array supplied is empty
     */
    public static boolean isEmpty(Object[] array) {
        return array == null || array.length == 0;
    }

    /**
     * Check if the list supplied is empty. An array is empty when it is null or when the length is 0
     *
     * @param list
     *          the list to check
     * @return true if the supplied list is empty
     */
    public static boolean isEmpty(List<?> list) {
        return list == null || list.size() == 0;
    }
}

Related

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