Write a generic class DynArray<T> backed by an array that starts with capacity 2 and doubles when full (print (capacity grows to 4) each time). Methods: add, get(i), removeAt(i) (shifts the tail left and returns the removed element), size(), capacity(), toString() → [a, b]. Invalid indexes throw IndexOutOfBoundsException("index 9, size 2").
DynArrayApp.main uses a DynArray<String> and reads commands add x, get i, remove i, show, printing error: … for bad indexes.
For the input
add a add b show add c show get 1 remove 0 show get 9
the program prints
[a, b] size 2, capacity 2
(capacity grows to 4)
[a, b, c] size 3, capacity 4
get(1) = b
removed a
[b, c] size 2, capacity 4
error: index 9, size 2