List of utility methods to do List Create
List | asList(Collection as List if (items == null) { return null; if (items instanceof List) { return (List<T>) items; return new ArrayList<T>(items); |
List | asList(E... elements) as List if (elements == null || elements.length == 0) { return Collections.emptyList(); int capacity = computeListCapacity(elements.length); ArrayList<E> list = new ArrayList<E>(capacity); Collections.addAll(list, elements); return list; |
List | asList(E[] array) as List if (isEmpty(array)) { return new ArrayList<>(); return Arrays.asList(array); |
List | asList(final int... values) Returns a List List<Integer> representation of an primitive int array. if (values == null) throw new IllegalArgumentException("the input array cannot be null"); return new AbstractList<Integer>() { @Override public Integer get(final int index) { return values[index]; @Override ... |
ArrayList | asList(final Iterator Returns data converted into list. final ArrayList<T> list = new ArrayList<T>(); while (data.hasNext()) { list.add(data.next()); return list; |
ArrayList | asList(int[] a) as List ArrayList list = new ArrayList(a.length); for (int i = 0; i < a.length; i++) { list.add(new Integer(a[i])); return list; |
List | asList(int[] array) needed because Arrays.asList() won't to autoboxing, so if you give it a primitive array you get a singleton list back with just that array as an element. List<Integer> l = new ArrayList<>(); for (int i : array) { l.add(i); return l; |
List | asList(Iterable as List return asList(iteratable, new ArrayList<>()); |
Collection | asList(Object[] array) as List Collection result = new ArrayList(array.length); for (int i = 0; i < array.length; i++) { result.add(array[i]); return result; |
List | asList(Object[] array) Returns the list view of given array or null if array is null. return array == null ? null : Arrays.asList(array);
|