public void insert(int n,int value){
  if (n > size) {
    throw new IndexOutOfBoundsException("n > size()");
  }
  growIfNeeded();
  System.arraycopy(values,n,values,n + 1,size - n);
  values[n]=value;
  size++;
  sorted=sorted && (n == 0 || value > values[n - 1]) && (n == (size - 1) || value < values[n + 1]);
}

public void insert ( int n , int value ) { if ( n > size ) { throw new IndexOutOfBoundsException ( "n > size()" ) ; } growIfNeeded ( ) ; System . arraycopy ( values , n , values , n + 1 , size - n ) ; values [ n ] = value ; size ++ ; sorted = sorted && ( n == 0 || value > values [ n - 1 ] ) && ( n == ( size - 1 ) || value < values [ n + 1 ] ) ; }
inserts element into specified index , moving elements at and above that index up one . may not be used to insert at an index beyond the current size ( that is , insertion as a last element is legal but no further ) .
