Open In App

Convert Iterator to Iterable in Java

Given an Iterator, the task is to convert it into Iterables in Java.

Examples:



Input: Iterator = {1, 2, 3, 4, 5}
Output: {1, 2, 3, 4, 5}

Input: Iterator = {'G', 'e', 'e', 'k', 's'}
Output: {'G', 'e', 'e', 'k', 's'}

Below are the various ways to do so:


Article Tags :