Java List First Item first_nItems(int n, Collection fromList)

Here you can find the source of first_nItems(int n, Collection fromList)

Description

firsn Items

License

Apache License

Declaration

public static <T> List<T> first_nItems(int n, Collection<T> fromList) 

Method Source Code


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

import java.util.ArrayList;

import java.util.Collection;

import java.util.List;

public class Main {
    public static <T> List<T> first_nItems(int n, Collection<T> fromList) {
        if (n >= fromList.size())
            return new ArrayList<T>(fromList);
        return (new ArrayList<T>(fromList)).subList(0, n);
    }/*from w  w  w  .j a  v a 2 s  . c  o  m*/
}

Related

  1. first(List list)
  2. first(List list)
  3. first(List list)
  4. first(List list)
  5. first(List list)
  6. firstBoolean(List list)
  7. firstColumnRemovable(List data)
  8. firstElement(List list)
  9. firstItem(Iterable list)