ArrayList(E[] array) { a = Objects.requireNonNull(array); }
@Override publicintsize(){ return a.length; }
@Override public Object[] toArray() { return a.clone(); }
@Override @SuppressWarnings("unchecked") public T[] toArray(T[] a) { int size = size(); if (a.length return Arrays.copyOf(this.a, size, (Class extends T[]>) a.getClass()); System.arraycopy(this.a, 0, a, 0, size); if (a.length > size) a[size] = null; return a; }
@Override public E get(int index){ return a[index]; }
@Override public E set(int index, E element){ E oldValue = a[index]; a[index] = element; return oldValue; }
@Override publicintindexOf(Object o){ E[] a = this.a; if (o == null) { for (int i = 0; i if (a[i] == null) return i; } else { for (int i = 0; i if (o.equals(a[i])) return i; } return -1; }
@Override public Spliteratorspliterator(){ return Spliterators.spliterator(a, Spliterator.ORDERED); }
@Override publicvoidforEach(Consumer super E> action){ Objects.requireNonNull(action); for (E e : a) { action.accept(e); } }
@Override publicvoidreplaceAll(UnaryOperator operator){ Objects.requireNonNull(operator); E[] a = this.a; for (int i = 0; i a[i] = operator.apply(a[i]); } }
@Override publicvoidsort(Comparator super E> c){ Arrays.sort(a, c); } }