code: public static <T, K> K[] toArray(Collection<T> entities,
  			Function<T, K> keyMapper, K[] arr) {
  		if (entities == null)
  			return null;
  		return entities.stream().map(keyMapper).toArray(size -> arr);
  	}
docs: Extract attribute from objects in collection and store them in array and
  return.
  
  @param entities
  @param keyMapper
  @param arr
  @return