public boolean addAll(int index,Collection c){
  int numNew=c.size();
synchronized (this) {
    Object[] elements=getArray();
    int len=elements.length;
    if (index > len || index < 0)     throw new IndexOutOfBoundsException("Index: " + index + ", Size: "+ len);
    if (numNew == 0)     return false;
    int numMoved=len - index;
    Object[] newElements;
    if (numMoved == 0)     newElements=copyOf(elements,len + numNew);
 else {
      newElements=new Object[len + numNew];
      System.arraycopy(elements,0,newElements,0,index);
      System.arraycopy(elements,index,newElements,index + numNew,numMoved);
    }
    for (Iterator itr=c.iterator(); itr.hasNext(); ) {
      Object e=itr.next();
      newElements[index++]=e;
    }
    setArray(newElements);
    return true;
  }
}

public boolean addAll ( int index , Collection c ) { int numNew = c . size ( ) ; synchronized ( this ) { Object [ ] elements = getArray ( ) ; int len = elements . length ; if ( index > len || index < 0 ) throw new IndexOutOfBoundsException ( "Index: " + index + ", Size: " + len ) ; if ( numNew == 0 ) return false ; int numMoved = len - index ; Object [ ] newElements ; if ( numMoved == 0 ) newElements = copyOf ( elements , len + numNew ) ; else { newElements = new Object [ len + numNew ] ; System . arraycopy ( elements , 0 , newElements , 0 , index ) ; System . arraycopy ( elements , index , newElements , index + numNew , numMoved ) ; } for ( Iterator itr = c . iterator ( ) ; itr . hasNext ( ) ; ) { Object e = itr . next ( ) ; newElements [ index ++ ] = e ; } setArray ( newElements ) ; return true ; } }
inserts all of the elements in the specified collection into this list , starting at the specified position . shifts the element currently at that position ( if any ) and any subsequent elements to the right ( increases their indices ) . the new elements will appear in this list in the order that they are returned by the specified collection ' s iterator .
