Android examples for java.util:List Sub List
Get sub List from a List
//package com.book2s; import java.util.List; import java.util.Vector; public class Main { public static void main(String[] argv) { List list = java.util.Arrays.asList("asdf", "book2s.com"); int fromIndex = 42; int toIndex = 42; System.out.println(subList(list, fromIndex, toIndex)); }//from w w w . ja v a2 s .co m /** * * @param <T> * @param list * @param fromIndex * @param toIndex * @return */ public static <T> List<T> subList(List<T> list, int fromIndex, int toIndex) { List<T> subList = new Vector<T>(toIndex - fromIndex); for (int i = Math.max(0, fromIndex); ((i < toIndex) && (i < list .size())); i++) { T obj = list.get(i); subList.add(obj); } return subList; } }