List of utility methods to do List from Array
ArrayList | array2ArrayList(final T[] array) Converts an array to the appropriate ArrayList if ((array == null) || (array.length == 0)) { return new ArrayList<T>(); final List<T> list = Arrays.asList(array); return new ArrayList<T>(list); |
List | array2List(Object[] obj) Converts an Object[] to a List. ArrayList list = new ArrayList(); if (obj != null) { for (int i = 0; i < obj.length; i++) { list.add(obj[i]); return (list); |
List | array2list(String[] array) arraylist List<String> list = new ArrayList<>(array.length); for (String value : array) { list.add(value); return list; |
List | array2List(T... array) Convert array to List Example: List return Arrays.asList(array);
|
ArrayList | arrayAsArrayList(E... elements) array As Array List if (elements == null) { throw new NullPointerException("elements"); return new ArrayList<>(Arrays.asList(elements)); |
List | arrayAsList(Object value) Transforms any array to a matching list List list = null; if (value instanceof int[]) { list = new ArrayList(); int[] array = (int[]) value; for (int i : array) { list.add(i); } else if (value instanceof short[]) { ... |
List | arrayAsList(Object[] array) Replacement for Arrays.asList(..) which gacks on null and returns a List in which remove is an unsupported operation. if ((null == array) || (1 > array.length)) { return Collections.emptyList(); ArrayList<Object> list = new ArrayList<Object>(); list.addAll(Arrays.asList(array)); return list; |
List | arrayAsListCopy(T... array) array As List Copy List<T> list = new ArrayList<>(); list.addAll(Arrays.asList(array)); return list; |
List | arrayAsListEmptyIfNull(T[] array) array As List Empty If Null return array == null ? Collections.<T>emptyList() : Arrays.asList(array);
|
boolean | arrayContainsValue(final String[] list, final String value) array Contains Value final List<String> valuesList = Arrays.asList(list); return valuesList.contains(value); |