Java List Sub List subList(List list, int start, int end)

Here you can find the source of subList(List list, int start, int end)

Description

Returns a section of the given list.

License

sencha.com license

Parameter

Parameter Description
list the list
start the start index
end the end index

Return

the sub list

Declaration

public static <X> List<X> subList(List<X> list, int start, int end) 

Method Source Code

//package com.java2s;
/**//  w w w .j  a v  a  2 s .  c  om
 * Sencha GXT 3.0.1 - Sencha for GWT
 * Copyright(c) 2007-2012, Sencha, Inc.
 * licensing@sencha.com
 *
 * http://www.sencha.com/products/gxt/license/
 */

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**
     * Returns a section of the given list.
     * 
     * @param list the list
     * @param start the start index
     * @param end the end index
     * @return the sub list
     */
    public static <X> List<X> subList(List<X> list, int start, int end) {
        List<X> temp = new ArrayList<X>();
        for (int i = start; i < end; i++) {
            temp.add(list.get(i));
        }
        return temp;
    }
}

Related

  1. subList(List list, int[] indexs)
  2. subList(List origin, int start, int length)
  3. subList(List parentList, int start, int end)
  4. subList(List query, int first, int max)
  5. subList(List src, int preBatchCount)
  6. subListByStartAndEnd( List list, M start, M end)
  7. subListMaxSize(List list, int maxSize)
  8. subListPage(List baseList, int fromIndex, int maxPageSize)
  9. truncatedSubList(List inList, int start, int end)