Java tutorial
//package com.java2s; import java.util.List; public class Main { public static <T> List<? super T> limit(List<? super T> source, int size) { if ((source.size() == size) || (source.size() < size)) { return source; } else { return source.subList(0, size); } } }