Java List First Item firstItem(List items)

Here you can find the source of firstItem(List items)

Description

first Item

License

MIT License

Declaration

public static <T> T firstItem(List<T> items) 

Method Source Code

//package com.java2s;
/*/*from  www  .  j  a  va  2  s  .co  m*/
 * oxAuth is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
 *
 * Copyright (c) 2014, Gluu
 */

import java.util.Iterator;
import java.util.List;

public class Main {
    public static <T> T firstItem(List<T> items) {
        if (items == null) {
            return null;
        }

        Iterator<T> iterator = items.iterator();
        if (iterator.hasNext()) {
            return iterator.next();
        }

        return null;
    }
}

Related

  1. first_nItems(int n, Collection fromList)
  2. firstBoolean(List list)
  3. firstColumnRemovable(List data)
  4. firstElement(List list)
  5. firstItem(Iterable list)
  6. firstMatch(List src, String... lookup)
  7. firstObjectFromList(List list)
  8. firstOrDefault(List items)
  9. firstStartsWith(List lines, String startsWith)