Java Collection First first(Collection collection)

Here you can find the source of first(Collection collection)

Description

first

License

Open Source License

Declaration

public static <T> T first(Collection<? extends T> collection) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.Collection;

public class Main {
    public static <T> T first(Collection<? extends T> collection) {
        ArrayList<T> list = new ArrayList<>(collection);
        return list.isEmpty() ? null : list.get(0);
    }/*from  w ww .ja va2s  .c om*/
}

Related

  1. first(Collection collection)
  2. first(Collection collection)
  3. first(Collection items)
  4. first(Collection collection, E alternative)
  5. first(Collection collection)
  6. first(Collection values)
  7. first(Collection collection)
  8. first(Collection self)