Returns an Optional containing the first element in this fluent iterable. If the iterable is empty, Optional.absent() is returned. Stream equivalent: if the goal is to obtain any element, stream.findAny(); if it must specifically be the first element
()
| 520 | |
| 521 | |
| 522 | public final Optional<E> first() { |
| 523 | Iterator<E> iterator = iterable.iterator(); |
| 524 | return iterator.hasNext() ? Optional.of(iterator.next()) : Optional.<E>absent(); |
| 525 | } |
| 526 | |
| 527 | /** |
| 528 | * Returns an {@link Optional} containing the last element in this fluent iterable. If the |