public static <T>List<T> copyToArrayListWithExtraCapacity(T[] elements,int extraCapacity){
  List<T> asList;
  if (elements != null) {
    asList=new ArrayList<T>(elements.length + extraCapacity);
    asList.addAll(Arrays.asList(elements));
  }
 else {
    asList=new ArrayList<T>(extraCapacity);
  }
  return asList;
}

public static < T > List < T > copyToArrayListWithExtraCapacity ( T [ ] elements , int extraCapacity ) { List < T > asList ; if ( elements != null ) { asList = new ArrayList < T > ( elements . length + extraCapacity ) ; asList . addAll ( Arrays . asList ( elements ) ) ; } else { asList = new ArrayList < T > ( extraCapacity ) ; } return asList ; }
produces an arraylist for an array of elements where the list is pre - sized with extra capacity . the extra capacity does not change the size of the list , but does change the initial capacity of the list , thus making adds more efficient if the ultimate size can be estimated .
