List of utility methods to do Array to List
String | arrayToCommaList(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(); |
String | arrayToCommaList(String[] array) Converts an array of strings into a comma seperated string. return arrayToList(array, ","); |
List | arrayToList(final T... items) array To List return Arrays.asList(items);
|
String | arrayToList(int[] intArr, int cnt) array To List return arrayToList(intArr, 0, cnt);
|
List | arrayToList(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; |
ArrayList | arrayToList(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; |
String | arrayToList(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; |
List | arrayToList(String[] str) array To List List list = Arrays.asList(str);
return list;
|
List | arrayToList(T[] array) Puts varargs in a mutable list. List<T> list = new LinkedList<>(); Collections.addAll(list, array); return list; |
List | arrayToList(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; |