Mon. Oct 3rd, 2022

Ever have one of those objects that want to give you an iterator and don’t have a method for getting it as a list? Well created another new method for my ListUtils class. ListUtils::iteratre() it takes an iterator and converts it into a List for you.

    /**
     * Convert and Iterator of E to a List of E
     * @param iterator Iterator of E to convert
     * @param <E> Type to iterate over
     * @return List of E converted.
     */
    public static <E> List<E> iterate(Iterator<E> iterator) {
        Iterable<E> iterable = () -> iterator;
        return  StreamSupport.stream(iterable.spliterator(), false).collect(Collectors.toList());
    }

By Jeffery Miller

I am known for being able to quickly decipher difficult problems to assist development teams in producing a solution. I have been called upon to be the Team Lead for multiple large-scale projects. I have a keen interest in learning new technologies, always ready for a new challenge.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: