ArrayList(E[] array) { a = Objects.requireNonNull(array); }
@Override publicintsize() { return a.length; }
@Override public Object[] toArray() { return Arrays.copyOf(a, a.length, Object[].class); }
@Override @SuppressWarnings("unchecked") public <T> T[] toArray(T[] a) { intsize= size(); if (a.length < size) return Arrays.copyOf(this.a, size, (Class<? extendsT[]>) 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) { EoldValue= a[index]; a[index] = element; return oldValue; }
@Override publicintindexOf(Object o) { E[] a = this.a; if (o == null) { for (inti=0; i < a.length; i++) if (a[i] == null) return i; } else { for (inti=0; i < a.length; i++) if (o.equals(a[i])) return i; } return -1; }