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

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

Description

Sublists the given list.

License

Apache License

Declaration

public static <K> List<K> subList(List<K> list, int begin, int end) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;
import java.util.List;

public class Main {
    /**/*from   www. j  a v a 2  s .  c  o m*/
     * Sublists the given list.
     */
    public static <K> List<K> subList(List<K> list, int begin, int end) {
        List<K> temp = new ArrayList<>(end - begin);
        for (int i = begin; i <= end; i++) {
            temp.add(list.get(i));
        }
        return temp;
    }
}

Related

  1. subList(List list, int fromIndex, int toIndex)
  2. subList(List list, int page, int size)
  3. subList(List list, int fromIndex)
  4. subList(List list, int skip, int top)
  5. subList(List list, int start, int end)
  6. subList(List lst, Collection indices)
  7. subList(List initial, int threshold)
  8. subList(List input, int startIndex, int count)
  9. subList(List input, int startIndex, int count)