Example usage for java.util List size

List of usage examples for java.util List size

Introduction

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

Prototype

int size();

Source Link

Document

Returns the number of elements in this list.

Usage

From source file:Main.java

public static <T> T last(List<T> list) {
    return list.get(list.size() - 1);
}

From source file:Main.java

public static long[] toArray(List<Long> list) {
    long[] n = new long[list.size()];
    for (int i = 0; i < list.size(); i++) {
        n[i] = list.get(i);/*  ww w . jav  a2s .c  o m*/
    }
    return n;
}

From source file:Main.java

public static boolean listIsBlank(List<Object> list) {
    return list == null || list.size() <= 0;
}

From source file:Main.java

public static Object[] listToArray(List<?> list) {
    return list.toArray(new Object[list.size()]);
}

From source file:Main.java

public static boolean isEmpty(List<?> list) {
    if (list == null || list.size() == 0)
        return true;
    return false;
}

From source file:Main.java

public static <T> T getLastOrNull(List<T> l) {
    final int size = l.size();
    if (size == 0)
        return null;
    return l.get(size - 1);
}

From source file:Main.java

public final static <T> boolean isEmptyList(List<T> aList) {
    if (null == aList || 0 == aList.size()) {
        return true;
    }/* www.ja  va  2s .  c om*/
    return false;
}

From source file:Main.java

public static <T> List<? super T> limit(List<? super T> source, int size) {
    if ((source.size() == size) || (source.size() < size)) {
        return source;
    } else {/*from  ww  w.j a  v  a 2s  . c  o  m*/
        return source.subList(0, size);
    }
}

From source file:Main.java

@SuppressWarnings("rawtypes")
public static void addComboBoxItems(JComboBox comboBox, List items) {
    for (int i = 0; i < items.size(); i++) {
        comboBox.addItem(items.get(i));/*from www .j ava2 s . c om*/
    }
}