Here you can find the source of extractFirst(int numberToExtract, List
public static <T extends Comparable<T>> List<T> extractFirst(int numberToExtract, List<T> list)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.List; public class Main { public static <T extends Comparable<T>> List<T> extractFirst(int numberToExtract, List<T> list) { List<T> topList = new ArrayList<T>(); for (int i = 0; i < numberToExtract && i < list.size(); i++) { topList.add(list.get(i));/*from w ww . j a v a2 s .c o m*/ } return topList; } }