SparseArray { public T get(int index) { if (index < 0) throw new IndexOutOfBoundsException(Integer.toString(index)); if (!definedElements.get(index)) { ensureCapacity(index); internalArray[index] = initialValue(); definedElements.set(index); } return internalGet(index); } SparseArray(int initialCapacity);  SparseArray(); int lastDefinedIndex(); boolean isCompactable(); @SuppressWarnings("unchecked") // T[] is just erased to Object[] anyway, which is what we have List<T> toList(); T get(int index); T getIfDefined(int index); T set(int index, T item); boolean isDefined(int index); boolean isEmpty(); void clear(); String describeElements(); StringBuilder describeElements(StringBuilder sb); @Override String toString();  }
@Test(expected = IndexOutOfBoundsException.class) public void negativeIndex() { new CountingSparseArray().get(-1); }