Java Utililty Methods List from Array

List of utility methods to do List from Array

Description

The list of methods to do List from Array are organized into topic(s).

Method

ListasList(Collection c)
as List
if (c instanceof List) {
    return (List<T>) c;
} else {
    ArrayList<T> copy = new ArrayList<T>();
    copy.addAll(c);
    return copy;
ListasList(Collection coll)
as List
return new ArrayList<T>(coll);
ListasList(Collection collection)
as List
return new ArrayList<T>(collection);
ListasList(double[] array)
as List
List<Double> list = new ArrayList<Double>(array.length);
for (int i = 0; i < array.length; i++)
    list.add(array[i]);
return list;
ListasList(E... elements)
Converts a variable argument array into a List.
List<E> list = new ArrayList<E>(elements.length);
for (E element : elements) {
    list.add(element);
return list;
ListasList(E... pEntities)
as List
if (pEntities != null) {
    List<E> entities = new ArrayList<>();
    for (E entity : pEntities) {
        entities.add(entity);
    return entities;
return Collections.emptyList();
...
ListasList(E[] array)

Given an array of a particular type, it will return it as a List of the same type.

List<E> list = new ArrayList<E>(array.length);
for (int i = 0; i < array.length; i++) {
    list.add(array[i]);
return list;
ListasList(final char[] array)
as List
final ArrayList<Character> list = new ArrayList<Character>(array.length);
for (final char c : array) {
    list.add(Character.valueOf(c));
return list;
ListasList(final Collection collection)
as List
List<T> result;
if (collection instanceof List) {
    result = (List<T>) collection;
} else {
    result = newList(collection);
return result;
ListasList(final Collection c)
as List
if (c instanceof List) {
    return (List<T>) c;
return new ArrayList<>(c);