code: public int[] toArray(int[] dest) {
          if (dest == null || dest.length < size()) {
              dest = new int[size];
          }
          
          System.arraycopy(data, 0, dest, 0, size);
          return dest;
      }
docs: Returns an array containing all of the values in this list in
  proper sequence (from first to last value). If the list fits
  in the specified array, it is returned therein. Otherwise, a new
  array is allocated with the size of this list.
  
  @param dest the array into which the values of the list are to
  be stored, if it is big enough; otherwise, a new array is allocated
  for this purpose.
  @return an array containing the values of the list