Skip to content

Instantly share code, notes, and snippets.

@skyebook
Created August 11, 2015 21:02
Show Gist options
  • Save skyebook/a20bdf1b1b013e659407 to your computer and use it in GitHub Desktop.
Save skyebook/a20bdf1b1b013e659407 to your computer and use it in GitHub Desktop.
Clamped subList
package donald.trump.for.president;
import java.util.List;
public class ListUtils {
/**
* Return a list containing, at most, the number of requested objects. If
* there are less than <code>count</code> items present, all items in the
* list are returned.
*/
public static List clampedSubList(List list, int count) {
return list.subList(0, Math.min(count, list.size()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment