List of usage examples for java.util AbstractList isEmpty
boolean isEmpty();
From source file:com.oltpbenchmark.util.CollectionUtil.java
/** * Return the last item in an Iterable//from w w w . jav a2s.c om * @param <T> * @param items * @return */ public static <T> T last(Iterable<T> items) { T last = null; if (items instanceof AbstractList<?>) { AbstractList<T> list = (AbstractList<T>) items; last = (list.isEmpty() ? null : list.get(list.size() - 1)); } else { for (T t : items) { last = t; } } return (last); }