Java Array to List toList(T[] array)

Here you can find the source of toList(T[] array)

Description

Converts an array to a List .

License

Open Source License

Parameter

Parameter Description
T the type
array the array to convert

Return

the

Declaration

public static <T> List<T> toList(T[] array) 

Method Source Code


//package com.java2s;
import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/*  ww w .ja v a  2  s .  c o m*/
     * Converts an array to a {@link List}.
     * 
     * @param <T> the type
     * @param array the array to convert
     * @return the {@link List}
     */
    public static <T> List<T> toList(T[] array) {
        final List<T> result = new ArrayList<T>(array.length);
        for (final T element : array) {
            result.add(element);
        }
        return result;
    }
}

Related

  1. toList(T[] anArrayToConvert)
  2. toList(T[] arr)
  3. toList(T[] array)
  4. toList(T[] array)
  5. toList(T[] array)
  6. toList(T[] array)
  7. toList(U... array)
  8. toList(V... elements)
  9. toList(Value... values)