Java tutorial
//package com.java2s; import java.util.List; public class Main { public static List<?> lastSubList(List<?> origin, int count) { if (origin == null || count <= 0) { return origin; } if (origin.size() < count) { count = origin.size(); } return origin.subList(origin.size() - count, origin.size()); } public static List<?> subList(List<?> origin, int count) { if (origin == null || count <= 0) { return origin; } if (origin.size() < count) { count = origin.size(); } return origin.subList(0, count); } }