@SuppressWarnings("unchecked") @Override public E get(int index) { if (index >= size) { throwIndexOutOfBoundsException(index, size); } return (E) array[index]; }
@Override public E get(int location) { try { return a[location]; } catch (ArrayIndexOutOfBoundsException e) { throw java.util.ArrayList.throwIndexOutOfBoundsException(location, a.length); } }
/** * Replaces the element at the specified location in this {@code ArrayList} * with the specified object. * * @param index * the index at which to put the specified object. * @param object * the object to add. * @return the previous element at the index. * @throws IndexOutOfBoundsException * when {@code location < 0 || location >= size()} */ @Override public E set(int index, E object) { Object[] a = array; if (index >= size) { throwIndexOutOfBoundsException(index, size); } @SuppressWarnings("unchecked") E result = (E) a[index]; a[index] = object; return result; }
/** * Removes the object at the specified location from this list. * * @param index * the index of the object to remove. * @return the removed object. * @throws IndexOutOfBoundsException * when {@code location < 0 || location >= size()} */ @Override public E remove(int index) { Object[] a = array; int s = size; if (index >= s) { throwIndexOutOfBoundsException(index, s); } @SuppressWarnings("unchecked") E result = (E) a[index]; System.arraycopy(a, index + 1, a, index, --s - index); a[s] = null; // Prevent memory leak size = s; modCount++; return result; }
int s = size; if (index > s || index < 0) { throwIndexOutOfBoundsException(index, s);
int s = size; if (index > s || index < 0) { throwIndexOutOfBoundsException(index, s);
@Override public E get(int location) { try { return a[location]; } catch (ArrayIndexOutOfBoundsException e) { throw java.util.ArrayList.throwIndexOutOfBoundsException(location, a.length); } }
@Override public E get(int location) { try { return a[location]; } catch (ArrayIndexOutOfBoundsException e) { throw java.util.ArrayList.throwIndexOutOfBoundsException(location, a.length); } }
@SuppressWarnings("unchecked") @Override public E get(int index) { if (index >= size) { throwIndexOutOfBoundsException(index, size); } return (E) array[index]; }
@SuppressWarnings("unchecked") @Override public E get(int index) { if (index >= size) { throwIndexOutOfBoundsException(index, size); } return (E) array[index]; }
@Override public E get(int location) { try { return a[location]; } catch (ArrayIndexOutOfBoundsException e) { throw java.util.ArrayList.throwIndexOutOfBoundsException(location, a.length); } }
@Override public E get(int location) { try { return a[location]; } catch (ArrayIndexOutOfBoundsException e) { throw java.util.ArrayList.throwIndexOutOfBoundsException(location, a.length); } }
@Override public E get(int location) { try { return a[location]; } catch (ArrayIndexOutOfBoundsException e) { throw java.util.ArrayList.throwIndexOutOfBoundsException(location, a.length); } }
@SuppressWarnings("unchecked") @Override public E get(int index) { if (index >= size) { throwIndexOutOfBoundsException(index, size); } return (E) array[index]; }
@SuppressWarnings("unchecked") @Override public E get(int index) { if (index >= size) { throwIndexOutOfBoundsException(index, size); } return (E) array[index]; }
@SuppressWarnings("unchecked") @Override public E get(int index) { if (index >= size) { throwIndexOutOfBoundsException(index, size); } return (E) array[index]; }
@Override public E get(int location) { try { return a[location]; } catch (ArrayIndexOutOfBoundsException e) { throw java.util.ArrayList.throwIndexOutOfBoundsException(location, a.length); } }
@SuppressWarnings("unchecked") @Override public E get(int index) { if (index >= size) { throwIndexOutOfBoundsException(index, size); } return (E) array[index]; }
/** * Replaces the element at the specified location in this {@code ArrayList} * with the specified object. * * @param index * the index at which to put the specified object. * @param object * the object to add. * @return the previous element at the index. * @throws IndexOutOfBoundsException * when {@code location < 0 || location >= size()} */ @Override public E set(int index, E object) { Object[] a = array; if (index >= size) { throwIndexOutOfBoundsException(index, size); } @SuppressWarnings("unchecked") E result = (E) a[index]; a[index] = object; return result; }
/** * Removes the object at the specified location from this list. * * @param index * the index of the object to remove. * @return the removed object. * @throws IndexOutOfBoundsException * when {@code location < 0 || location >= size()} */ @Override public E remove(int index) { Object[] a = array; int s = size; if (index >= s) { throwIndexOutOfBoundsException(index, s); } @SuppressWarnings("unchecked") E result = (E) a[index]; System.arraycopy(a, index + 1, a, index, --s - index); a[s] = null; // Prevent memory leak size = s; modCount++; return result; }