// Code written in class for basic ArrayList functionality. public class MyArrayList{ T [] A; //array of T int size; @SuppressWarnings("unchecked") public MyArrayList(){ //A=new T[10]; A=(T[])new Object[10]; size=0; } public int size(){ return size; //this is not A.length } public T get(int i){ if(i<0 || i>=size) throw new IndexOutOfBoundsException("shit this is out of bound: "+i); return A[i]; } public void set(int i, T x){ if(i<0 || i>=size) throw new IndexOutOfBoundsException("shit this is out of bound: "+i); A[i]=x; } @SuppressWarnings("unchecked") public void add(T x) { if(size==A.length) { T [] B=(T[])new Object[ A.length*2 ]; for(int j=0;j=size) throw new IndexOutOfBoundsException("shit this is out of bound: "+i);; if(size==A.length) { T [] B=(T[])new Object[ A.length*2 ]; for(int j=0;ji;j--) A[j]=A[j-1]; A[i+1]=x; size++; } public void remove(int i) { if(i<0 || i>=size) throw new IndexOutOfBoundsException("shit this is out of bound: "+i);; for(int j=i;j A=new MyArrayList(); A.add("haha"); A.add("foo"); A.add("boo"); A.insert(1,"test"); A.print(); A.remove(2); A.print(); } }