### Question:
ArrayList extends List<E> { @Override public Object[] toArray() { Object[] result = new Object[itemCount]; SystemUtils.arraycopy(array, firstIndex, result, 0, itemCount); return result; } ArrayList();  ArrayList(int capacity);  ArrayList(Collection<E> collection);  ArrayList(E... args); @Override void add(int location, E object); @Override boolean add(E object); @Override boolean addAll(int location, Collection<? extends E> collection); @Override boolean addAll(Collection<? extends E> collection); @Override void clear(); @Override boolean contains(E object); void ensureCapacity(int minimumCapacity); @Override E get(int location); @Override int indexOf(E object); @Override boolean isEmpty(); @Override int lastIndexOf(E object); @Override Iterator<E> iterator(); @Override E remove(int location); @Override boolean remove(E object); @Override E set(int location, E object); @Override int size(); @Override Object[] toArray(); @Override void toArray(E[] contents); void sortInPlace(Comparator<E> comparator); void trimToSize();  }### Answer:
@Test public void testToArray() { alist.set(25, null); alist.set(75, null); Object[] argArray = new Object[alist.size()]; alist.toArray(argArray); argArray = new Object[1000]; alist.toArray(argArray); assertNull("Failed to set first extra element to null", argArray[alist.size()]); for (int i = 0; i < 100; i++) { if ((i == 25) || (i == 75)) { assertNull("Should be null: " + i, argArray[i]); } else { assertTrue("Returned incorrect array: " + i, argArray[i] == objArray[i]); } } }