code: public static int[] toIntArray(Collection<Integer> collection) {
          int[] collectionArray = new int[collection.size()];
          int index = 0;
          for (Integer item : collection) {
              collectionArray[index++] = item;
          }
          return collectionArray;
      }
docs: Converts a {@link Collection<Integer>} to a primitive {@code int[]} array.
  
  @param collection the given collection
  @return a primitive int[] array
  @throws NullPointerException if collection is {@code null}