@Override @SuppressWarnings("unchecked") public <T>T[] toArray(T[] array){
  if (array.length < size) {
    Class arrayType=array.getClass();
    T[] copy=(arrayType == Object[].class) ? (T[])new Object[size] : (T[])Array.newInstance(arrayType.getComponentType(),size);
    System.arraycopy(buffer,start,copy,0,size);
    return copy;
  }
  System.arraycopy(buffer,start,array,0,size);
  if (array.length > size) {
    array[size]=null;
  }
  return array;
}

@ Override @ SuppressWarnings ( "unchecked" ) public < T > T [ ] toArray ( T [ ] array ) { if ( array . length < size ) { Class arrayType = array . getClass ( ) ; T [ ] copy = ( arrayType == Object [ ] . class ) ? ( T [ ] ) new Object [ size ] : ( T [ ] ) Array . newInstance ( arrayType . getComponentType ( ) , size ) ; System . arraycopy ( buffer , start , copy , 0 , size ) ; return copy ; } System . arraycopy ( buffer , start , array , 0 , size ) ; if ( array . length > size ) { array [ size ] = null ; } return array ; }
returns an array containing all of the elements in this list in proper sequence ( from first to last element ) ; the runtime type of the returned array is that of the specified array . if the list fits in the specified array , it is returned therein . otherwise , a new array is allocated with the runtime type of the specified array and the size of this list .
