class MyArrayList4 { private T[] array; private int count; public MyArrayList4() { array = (T[]) new Object[10]; } public T get(int i) { if(i>=count) throw new IndexOutOfBoundsException(); return array[i]; } public void set(int i,T item) { if(i>=count) throw new IndexOutOfBoundsException(); array[i]=item; } private void expand() { T[] array1 = (T[]) new Object[array.length*2]; for(int i=0; icount) throw new IndexOutOfBoundsException(); if(count==array.length) expand(); for(int i=count; i>pos; i--) array[i]=array[i-1]; array[pos]=item; count++; } public T remove(int pos) { if(pos>=count) throw new IndexOutOfBoundsException(); T removed = array[pos]; for(int i=pos+1; i=0&&!array[i].equals(item); i--) {} return i; } public String toString() { String str = "["; if(count>0) str+=array[0]; for(int i=1; i