Java Utililty Methods Array to List

List of utility methods to do Array to List

Description

The list of methods to do Array to List are organized into topic(s).

Method

StringarrayToCommaList(Object[] array)
Format an array of Object as a list with commas, like "apples, oranges, and bananas"); XXX Should have a boolean for the final comma :-)
StringBuffer sb = new StringBuffer();
for (int i = 0; i < array.length; i++) {
    if (i > 0 && i < array.length - 1) {
        sb.append(',');
    if (i > 0) {
        sb.append(' ');
    if (i == (array.length - 1)) {
        sb.append("and ");
    sb.append(array[i]);
return sb.toString();
StringarrayToCommaList(String[] array)
Converts an array of strings into a comma seperated string.
return arrayToList(array, ",");
ListarrayToList(final T... items)
array To List
return Arrays.asList(items);
StringarrayToList(int[] intArr, int cnt)
array To List
return arrayToList(intArr, 0, cnt);
ListarrayToList(Object[] objs)
array To List
if (objs == null)
    return null;
List ret = new ArrayList(objs.length);
for (Object obj : objs) {
    ret.add(obj);
return ret;
ArrayListarrayToList(String... stringArray)
Retrieves an array list containing the contents of the provided array.
if (stringArray == null) {
    return null;
ArrayList<String> stringList = new ArrayList<>(stringArray.length);
Collections.addAll(stringList, stringArray);
return stringList;
StringarrayToList(String[] array, String delim)
Converts an array of strings into a delimeter seperated string.
String result = "";
for (int i = 0; i < array.length; i++) {
    result += array[i] + ((i == (array.length - 1)) ? "" : delim);
return result;
ListarrayToList(String[] str)
array To List
List list = Arrays.asList(str);
return list;
ListarrayToList(T[] array)
Puts varargs in a mutable list.
List<T> list = new LinkedList<>();
Collections.addAll(list, array);
return list;
ListarrayToList(T[] t)
array To List
if (t == null || t.length == 0) {
    return new ArrayList<T>(0);
List<T> list = new ArrayList<T>(t.length);
Collections.addAll(list, t);
return list;