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

ArrayListarray2ArrayList(final T[] array)
Converts an array to the appropriate ArrayList
if ((array == null) || (array.length == 0)) {
    return new ArrayList<T>();
final List<T> list = Arrays.asList(array);
return new ArrayList<T>(list);
Listarray2List(Object[] obj)
Converts an Object[] to a List.
ArrayList list = new ArrayList();
if (obj != null) {
    for (int i = 0; i < obj.length; i++) {
        list.add(obj[i]);
return (list);
Listarray2list(String[] array)
arraylist
List<String> list = new ArrayList<>(array.length);
for (String value : array) {
    list.add(value);
return list;
Listarray2List(T... array)
Convert array to List Example: List stooges = ArrayUtil.array2List("Larry", "Moe", "Curly");
return Arrays.asList(array);
ArrayListarrayAsArrayList(E... elements)
array As Array List
if (elements == null) {
    throw new NullPointerException("elements");
return new ArrayList<>(Arrays.asList(elements));
ListarrayAsList(Object value)
Transforms any array to a matching list
List list = null;
if (value instanceof int[]) {
    list = new ArrayList();
    int[] array = (int[]) value;
    for (int i : array) {
        list.add(i);
} else if (value instanceof short[]) {
...
ListarrayAsList(Object[] array)
Replacement for Arrays.asList(..) which gacks on null and returns a List in which remove is an unsupported operation.
if ((null == array) || (1 > array.length)) {
    return Collections.emptyList();
ArrayList<Object> list = new ArrayList<Object>();
list.addAll(Arrays.asList(array));
return list;
ListarrayAsListCopy(T... array)
array As List Copy
List<T> list = new ArrayList<>();
list.addAll(Arrays.asList(array));
return list;
ListarrayAsListEmptyIfNull(T[] array)
array As List Empty If Null
return array == null ? Collections.<T>emptyList() : Arrays.asList(array);
booleanarrayContainsValue(final String[] list, final String value)
array Contains Value
final List<String> valuesList = Arrays.asList(list);
return valuesList.contains(value);