Java Array to List toList(E[] array, int fromIndex, int toIndex)

Here you can find the source of toList(E[] array, int fromIndex, int toIndex)

Description

to List

License

LGPL

Parameter

Parameter Description
array the array to be converted into list
fromIndex the index of the first element, inclusive, to be sorted
toIndex the index of the last element, exclusive, to be sorted

Declaration

public static <E> List<E> toList(E[] array, int fromIndex, int toIndex) 

Method Source Code


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

import java.util.Arrays;

import java.util.List;

public class Main {
    /**/*from w w w  . java  2s  .  com*/
     *
     * @param array the array to be converted into list
     * @param fromIndex the index of the first element, inclusive, to be sorted
     * @param toIndex the index of the last element, exclusive, to be sorted
     * @return
     */
    public static <E> List<E> toList(E[] array, int fromIndex, int toIndex) {
        List<E> list = Arrays.asList(array);
        return list.subList(fromIndex, toIndex);
    }
}

Related

  1. toList(byte[] array)
  2. toList(double[] array)
  3. toList(double[] array)
  4. toList(E... e)
  5. toList(E... values)
  6. toList(final double[] array)
  7. toList(final E[] array)
  8. toList(final float[] array)
  9. toList(final int[] array)