Java Utililty Methods Iterable First

List of utility methods to do Iterable First

Description

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

Method

booleanequal(Iterable first, Iterable second)
Compare elements, sort order and length
return equal(first.iterator(), second.iterator());
Efirst(final Iterable iterable)
first
if (null == iterable) {
    return null;
final Iterator<E> it = iterable.iterator();
if (!it.hasNext()) {
    return null;
return it.next();
...
Tfirst(final Iterable iter)
first
return iter == null ? null : next(iter.iterator());
Tfirst(Iterable iterable)
first
return first(iterable.iterator());
Efirst(Iterable i)
first
Iterator<E> iterator = i.iterator();
if (!iterator.hasNext()) {
    throw new IllegalArgumentException("iterator has no elements");
return iterator.next();
Tfirst(Iterable iterable)
first
return first(iterable.iterator(), null);
Tfirst(Iterable iterable)
Returns the first element of the collection.
if (iterable instanceof Deque<?>)
    return ((Deque<T>) iterable).getFirst();
if (iterable instanceof List<?>) {
    List<T> list = (List<T>) iterable;
    return list.isEmpty() ? null : list.get(0);
Iterator<T> iterator = iterable.iterator();
return iterator.hasNext() ? iterator.next() : null;
...
EfirstElement(Iterable iterable)
Returns the first element of the given Iterable
final int indexPosition = 0;
return elementAt(iterable, indexPosition);
ObjectfirstElementOrNull(Iterable iterable)
first Element Or Null
Iterator iterator = iterable.iterator();
if (iterator.hasNext()) {
    return iterator.next();
} else {
    return null;
TfirstOf(final Iterable iterable)
first Of
return nthOf(iterable, 0);