Java Array to List toList(final T[] array)

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

Description

to List

License

Open Source License

Declaration

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

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.Arrays;

import java.util.List;

public class Main {
    public static <T> List<T> toList(final T[] array) {
        List<T> l = list(array.length);
        l.addAll(Arrays.asList(array));
        return l;
    }/*from w  ww .  ja  v a 2  s  .co m*/

    public static <T> List<T> list(final int initialCapacity) {
        return new ArrayList<T>(initialCapacity);
    }

    public static <T> List<T> list() {
        return new ArrayList<T>();
    }

    @SafeVarargs
    public static <T> List<T> list(final T... objects) {
        List<T> l = list();
        l.addAll(toList(objects));
        return l;
    }
}

Related

  1. ToList(final Object[] array)
  2. toList(final Object[] objects)
  3. toList(final T... objects)
  4. toList(final T[] array)
  5. toList(final T[] array)
  6. toList(final T[] array)
  7. toList(final T[] array)
  8. toList(int[] a)
  9. toList(int[] arr)