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

ListarrayToListWithUpperCase(String[] arrValues)
Convenience method to return a String array as a CSV String.
List values = null;
if (arrValues != null) {
    values = new ArrayList();
    int size = arrValues.length;
    for (int i = 0; i < size; i++) {
        values.add(arrValues[i] != null ? arrValues[i].toUpperCase() : null);
return values;
StringarrayToString(List arr)
array To String
if (arr == null || arr.isEmpty()) {
    return "";
StringBuilder buf = new StringBuilder();
arr.stream().forEach((str) -> {
    if (buf.length() > 0) {
        buf.append(", ");
    buf.append(str);
});
return buf.toString();
ListarrayToStringList(Object array)
array To String List
if (array == null)
    return null;
if (!array.getClass().isArray())
    return null;
Class<?> componentType = array.getClass().getComponentType();
if (componentType == null)
    return null;
if (String.class.isAssignableFrom(componentType)) {
...
ListasList()
as List
return new ArrayList<T>();
ListasList(boolean[] array)
as List
return new AbstractList<Boolean>() {
    @Override
    public int size() {
        return array.length;
    @Override
    public Boolean get(int index) {
        return array[index];
...
ListasList(byte[] array)
as List
return asList(array, 0, array.length);
List>asList(Class... classesArray)
as List
List<Class<?>> classes = new ArrayList<Class<?>>();
for (Class<?> clazz : classesArray) {
    classes.add(clazz);
return classes;
ListasList(Collection collection)
as List
List<E> result = new ArrayList<E>();
for (Object obj : collection) {
    result.add((E) obj);
return result;
ListasList(Collection collection, Class type)
Convert the collection to a typed list of given type.
List<T> list = new ArrayList<T>();
for (Object o : collection) {
    if (type.isInstance(o)) {
        list.add(type.cast(o));
return list;
ArrayListasList(Collection values)
Creates a new ArrayList from a collection by building an enumeration over the collection.
return Collections.list(Collections.<K>enumeration(values));