Here you can find the source of sub(Collection
public static <T> List<T> sub(Collection<T> list, int start, int end)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static <T> List<T> sub(List<T> list, int start, int end) { if (list == null || list.isEmpty()) { return null; }// ww w . j a v a 2 s . c o m if (start < 0) { start = 0; } if (end < 0) { end = 0; } if (start > end) { int tmp = start; start = end; end = tmp; } final int size = list.size(); if (end > size) { if (start >= size) { return null; } end = size; } return list.subList(start, end); } public static <T> List<T> sub(Collection<T> list, int start, int end) { if (list == null || list.isEmpty()) { return null; } return sub(new ArrayList<T>(list), start, end); } public static <T> boolean isEmpty(T[] array) { return array == null || array.length == 0; } public static boolean isEmpty(Collection<?> collection) { return collection == null || collection.isEmpty(); } public static boolean isEmpty(Map<?, ?> map) { return map == null || map.isEmpty(); } }