Java Iterable First first(Iterable iterable)

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

Description

first

License

Open Source License

Declaration

public static <T> T first(Iterable<? extends T> iterable) 

Method Source Code

//package com.java2s;
/*/*from w w w  . ja va  2 s  .  c  om*/
 *
 *  Managed Data Structures
 *  Copyright ? 2016 Hewlett Packard Enterprise Development Company LP.
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Lesser General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *  As an exception, the copyright holders of this Library grant you permission
 *  to (i) compile an Application with the Library, and (ii) distribute the 
 *  Application containing code generated by the Library and added to the 
 *  Application during this compilation process under terms of your choice, 
 *  provided you also meet the terms and conditions of the Application license.
 *
 */

import java.util.Iterator;

public class Main {
    public static <T> T first(Iterator<? extends T> iterator) {
        return iterator.next();
    }

    public static <T> T first(Iterable<? extends T> iterable) {
        return first(iterable.iterator());
    }
}

Related

  1. equal(Iterable first, Iterable second)
  2. first(final Iterable iterable)
  3. first(final Iterable iter)
  4. first(Iterable i)
  5. first(Iterable iterable)
  6. first(Iterable iterable)
  7. firstElement(Iterable iterable)