public static long[] toArray(List<Long> items){
  long[] array=new long[items.size()];
  int i=0;
  for (  Long item : items) {
    array[i++]=item;
  }
  return array;
}

public static long [ ] toArray ( List < Long > items ) { long [ ] array = new long [ items . size ( ) ] ; int i = 0 ; for ( Long item : items ) { array [ i ++ ] = item ; } return array ; }
converts a list of longs to an array of primitive longs .
