Java Iterable First firstElementOrNull(Iterable iterable)

Here you can find the source of firstElementOrNull(Iterable iterable)

Description

first Element Or Null

License

Apache License

Declaration

public static <K> Object firstElementOrNull(Iterable iterable) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Iterator;

public class Main {
    public static <K> Object firstElementOrNull(Iterable iterable) {
        Iterator iterator = iterable.iterator();
        if (iterator.hasNext()) {
            return iterator.next();
        } else {//from   w  w w  .  jav  a2 s  . c o m
            return null;
        }
    }
}

Related

  1. first(Iterable iterable)
  2. first(Iterable i)
  3. first(Iterable iterable)
  4. first(Iterable iterable)
  5. firstElement(Iterable iterable)
  6. firstOf(final Iterable iterable)
  7. firstOrNull(Iterable iterable)
  8. getFirst(final Iterable iterable)
  9. getFirst(final Iterable iterable)