Java Utililty Methods Collection First

List of utility methods to do Collection First

Description

The list of methods to do Collection First are organized into topic(s).

Method

TgetFirst(Collection col)
Get the first item from the collection.
return get(col, 0);
TgetFirst(Collection coll)
INTERNAL: Gets the first object in the collection.
if (coll == null || coll.isEmpty())
    return null;
if (coll instanceof List)
    return ((List<T>) coll).get(0);
Iterator<T> iter = coll.iterator();
while (iter.hasNext()) {
    return iter.next();
return null;
TgetFirst(Collection collection)
get First
if (isEmpty(collection)) {
    return null;
return collection.iterator().next();
TgetFirst(Collection collection)
get First
if (collection != null) {
    Iterator<T> iterator = collection.iterator();
    return iterator.hasNext() ? iterator.next() : null;
return null;
TgetFirst(Collection collection)
get First
if (isEmpty(collection)) {
    return null;
return collection.iterator().next();
TgetFirst(Collection collection)
get First
if (isEmpty(collection)) {
    return null;
if (collection instanceof List) {
    return ((List<T>) collection).get(0);
return collection.iterator().next();
TgetFirst(Collection collection)
get First
if (isEmpty(collection)) {
    return null;
return collection.iterator().next();
TgetFirst(Collection collection)
get First
if (isEmpty(collection)) {
    return null;
return collection.iterator().next();
TgetFirst(Collection l)
get First
return l.size() > 0 ? l.iterator().next() : null;
TgetFirst(Collection set)
get First
if (isNotEmpty(set)) {
    for (T item : set) {
        if (item != null) {
            return item;
return null;
...