Here you can find the source of sub(Collection coll, int first, int size)
public static Collection sub(Collection coll, int first, int size)
//package com.java2s; /**/*from ww w .j a v a2 s . c o m*/ * Copyright (c) 2004-2011 Wang Jinbao(Julian Wong), http://www.ralasafe.com * Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php */ import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.List; public class Main { public static Collection sub(Collection coll, int first, int size) { if (coll == null) { return null; } if (coll.size() < size && first == 0) { return coll; } else { List sub = new ArrayList(size); int i = -1; int fetchsize = 0; for (Iterator iter = coll.iterator(); iter.hasNext();) { Object object = (Object) iter.next(); i++; if (i < first) { continue; } sub.add(object); fetchsize++; if (fetchsize == size) { break; } } return sub; } } }