Java List Null Empty isEmpty(java.util.List list)

Here you can find the source of isEmpty(java.util.List list)

Description

Determine whether an List is null or empty.

License

Open Source License

Parameter

Parameter Description
list the list to examine.

Return

true if the list is null or zero-length.

Declaration

public static boolean isEmpty(java.util.List<?> list) 

Method Source Code

//package com.java2s;

public class Main {
    /**//  w w w .j a v  a2 s .c  o  m
     * Determine whether an object reference is null or a reference to an empty string.
     *
     * @param s the reference to examine.
     *
     * @return true if the reference is null or is a zero-length {@link String}.
     */
    public static boolean isEmpty(Object s) {
        return s == null
                || (s instanceof String && ((String) s).length() == 0);
    }

    /**
     * Determine whether an {@link List} is null or empty.
     *
     * @param list the list to examine.
     *
     * @return true if the list is null or zero-length.
     */
    public static boolean isEmpty(java.util.List<?> list) {
        return list == null || list.size() == 0;
    }
}

Related

  1. isEmpty(Collection list)
  2. isEmpty(final List aList)
  3. isEmpty(final List values, final int position)
  4. isEmpty(final List list)
  5. isEmpty(final List objList)
  6. isEmpty(List list)
  7. isEmpty(List values)
  8. isEmpty(List list)
  9. isEmpty(List aList)