ppkarwasz commented on code in PR #1411: URL: https://github.com/apache/commons-lang/pull/1411#discussion_r2203253282
########## src/main/java/org/apache/commons/lang3/ArrayUtils.java: ########## @@ -8862,6 +8865,63 @@ public static <T> T[] toArray(@SuppressWarnings("unchecked") final T... items) { return items; } + /** + * Converts an {@link Iterator} into an array. + * <p> + * Returns {@code null} if the input iterator is {@code null}. + * If the iterator has no elements, an empty {@code Object[]} is returned. + * </p> + * <p> + * Note: The returned array has runtime type {@code Object[]}, and requires that all elements + * in the iterator are of the same type. If a type-safe array is needed, use + * {@link #iteratorToArray(Iterator, Class)} instead. + * </p> + * + * @param iterator the iterator to convert, may be {@code null} + * @param <T> the element type + * @return the array containing elements from the iterator, + * or {@code null} if the input is {@code null} + * @since 3.18 + */ + @SuppressWarnings("unchecked") + public static <T> T[] iteratorToArray(Iterator<T> iterator) { Review Comment: Yes, `Object[]` would be more appropriate. It is also the only choice here. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org