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

ArrayListasList(T[] array)
Given an input array, will return an ArrayList representation of the array.
if (array == null) {
    return null;
ArrayList<T> list = new ArrayList<T>(array.length);
for (T e : array) {
    list.add(e);
return list;
...
ListasList(T[] array)
as List
List<T> list;
if (array != null) {
    list = Arrays.asList(array);
} else {
    list = Collections.emptyList();
return list;
ListasList(T[] array)
Converts an array to a List This method is similar to Arrays.asList, except that it returns a writeable list
if (array == null) {
    return new ArrayList<T>();
List<T> result = new ArrayList<T>(array.length);
for (T t : array) {
    result.add(t);
return result;
...
ListasList(T[] array)
as List
List<T> list = new ArrayList<T>();
for (T t : array) {
    list.add(t);
return list;
ListasList(T[] array)
as List
ArrayList<T> list = new ArrayList<T>();
Collections.addAll(list, array);
return list;
ListasListFromObjectArray(Object[] at)
as List From Object Array
final List<T> result = new ArrayList<T>(at.length);
for (Object t : at) {
    result.add((T) t);
assert result.size() == at.length;
return result;
ListconvertArrayToList(int[] ids)
convert Array To List
int i;
List result = null;
if (ids != null) {
    result = new ArrayList();
    for (i = 0; i < ids.length; ++i)
        result.add(new Integer(ids[i]));
return result;
...
ListconvertArrayToList(List list, String[] strs)
convert Array To List
if (null == strs) {
    return new ArrayList<String>(50);
if (null == list) {
    list = new ArrayList<String>(50);
list.addAll(Arrays.asList(strs));
return list;
...
ListconvertArrayToList(Object value)
convert Array To List
List list = new ArrayList();
if (value instanceof int[]) {
    int[] arr = (int[]) value;
    for (int ix = 0; ix < arr.length; ix++) {
        list.add(arr[ix]);
} else if (value instanceof double[]) {
    double[] arr = (double[]) value;
...
ListconvertArrayToList(Object[] objects)
convert Array To List
List rtnList = new ArrayList();
for (int i = 0; i < objects.length; i++) {
    rtnList.add(objects[i]);
return rtnList;