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(Iterable iterable)
as List
if (List.class.isAssignableFrom(iterable.getClass())) {
    return (List<T>) iterable;
} else {
    List<T> list = new ArrayList<T>();
    for (T item : iterable) {
        list.add(item);
    return list;
...
ListasList(Iterable iterable)
Returns a {List} of the contents for the given {Iterable}
List<T> list = new ArrayList<T>();
for (T item : iterable) {
    list.add(item);
return list;
ListasList(Iterable iterable)
as List
List<T> list = new ArrayList<T>();
Iterator<T> it = iterable.iterator();
while (it.hasNext()) {
    T element = it.next();
    if (element != null) {
        list.add(element);
return list;
ListasList(Iterator iterator)
as List
List<T> list = new ArrayList<T>();
while (iterator.hasNext())
    list.add(iterator.next());
return list;
StringasList(List list)
as List
StringBuffer buffer = new StringBuffer();
if (list != null) {
    if (list.size() == 1) {
        buffer.append(list.get(0));
    } else {
        for (String element : list) {
            buffer.append(element);
            buffer.append(", ");
...
ListasList(long... array)
as List
if (array == null)
    return Collections.emptyList();
List<Long> ret = new ArrayList<Long>(array.length);
for (long element : array) {
    ret.add(element);
return ret;
ListasList(Object info)
as List
List<Number> list = new ArrayList<Number>();
if (info instanceof int[]) {
    int[] array = (int[]) info;
    for (int i : array) {
        list.add(i);
} else if (info instanceof long[]) {
    long[] array = (long[]) info;
...
ListasList(Object o, Class cls)
as List
if (o == null)
    return null;
if (o instanceof Collection) {
    return asList((Collection<?>) o, cls);
return asList(newList(o), cls);
ListasList(Object theone)
Return a new List that contains [theone] element.
ArrayList single = new ArrayList(1);
single.add(theone);
return single;
ListasList(Object value)
as List
return (List<Object>) value;