. , , "" , get(int index) set(T value, int index) size.
" " , :
Holder<T> {
T[] array = (T[])new Object[10];
}
, , T[] array = new T[10], , java ( @SafeVarArgs ). , , ; , .
, add(T value), . , ,
Arrays.copyOfRange System.arrayCopy .
, T (look for generics bounds).
, delete ? null? ? , ? , - ? (: java , : ArrayList#trimToSize())
When your inner array is full and you want to add another element, how much would you expand it? 50%, 75%? Or enough space for one item? If you knew how jdk's internal collections work, the answer would be very simple.
I think this is not a bad question for interviews in all IMOs.
source
share