Example usage for java.util List isEmpty

List of usage examples for java.util List isEmpty

Introduction

In this page you can find the example usage for java.util List isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:Main.java

public static <T> boolean isEmpty(List<T> list) {
    if (list == null || list.isEmpty()) {
        return true;
    }/*  w  w  w.  j  ava  2 s.  c o  m*/
    return false;
}

From source file:Main.java

public static boolean isEmpty(List list) {
    if (list != null && !list.isEmpty()) {
        return false;
    }/*from  w ww .j a  v a 2s. co m*/
    return true;
}

From source file:Main.java

public static Object[] toArrayOnListOfSameType(List aList) {
    if (aList.isEmpty())
        return new Object[0];

    Class type = aList.get(0).getClass();
    Object[] sameElementsArray = (Object[]) Array.newInstance(type, aList.size());
    return aList.toArray(sameElementsArray);
}

From source file:Main.java

public static <T> T getHead(List<T> list) {
    if (list == null || list.isEmpty()) {
        return null;
    }/*from   w w w  . ja v  a  2s  . c  o  m*/
    return list.get(0);
}

From source file:Main.java

public static <T> T getTail(List<T> list) {
    if (list == null || list.isEmpty()) {
        return null;
    }//from w  w w.  ja  v  a 2  s .c om
    return list.get(list.size() - 1);
}

From source file:Main.java

public static boolean isNullOrEmpty(List list) {
    return list == null || list.isEmpty();
}

From source file:Main.java

public static boolean isNullOrEmpty(List<?> list) {
    return list == null || list.isEmpty();
}

From source file:Main.java

public static <E> boolean validate(List<E> list) {
    return list != null && !list.isEmpty();
}

From source file:Main.java

public static boolean isListEmpty(List<?> list) {
    return list == null || list.isEmpty();
}

From source file:Main.java

public static boolean any(List<?> list) {
    return (list != null && !list.isEmpty());
}