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(String... args)
as List
if (args == null)
    return null;
List<String> list = new ArrayList<String>();
for (String arg : args) {
    list.add(arg);
return list;
ListasList(String... strings)
Returns from a variable number of String parameters a List<String>
List<String> listOfStrings = new ArrayList<>(strings.length);
for (int i = 0; i < strings.length; i++) {
    listOfStrings.add(strings[i]);
return listOfStrings;
ListasList(T element)
as List
return Collections.singletonList(element);
ListasList(T firstItem, T... otherItems)
as List
List<T> list = new ArrayList<>(otherItems.length + 1);
list.add(firstItem);
Collections.addAll(list, otherItems);
return list;
ListasList(T... a)
as List
if (a == null) {
    return new ArrayList<T>();
ArrayList<T> list = new ArrayList<T>(a.length);
list.addAll(Arrays.asList(a));
return list;
ArrayListasList(T... a)
Return an ArrayList with the passed array or elements as the initial contents.
ArrayList<T> result = new ArrayList<T>();
for (T t : a) {
    result.add(t);
return result;
ListasList(T... a)
as List
List<T> rtn = null;
if (a != null) {
    rtn = Arrays.asList(a);
return rtn;
ListasList(T... a)
Returns a list backed by the specified array.
ArrayList<T> list = new ArrayList<T>();
for (T elem : a)
    list.add(elem);
return list;
ListasList(T... args)
as List
if (args == null || args.length == 0) {
    return Collections.emptyList();
} else {
    return Arrays.asList(args);
ListasList(T... args)
Null-safe version of java.util.Arrays#asList(Object[])
return args == null ? null : Arrays.asList(args);