Online Java Compiler By
JavaTpoint.com
import java.util.Collection; import java.util.Iterator; import java.util.concurrent.LinkedBlockingDeque; public class JavaCollectionIteratorExample3 { public static void main(String[] args) { Collection
collection = new LinkedBlockingDeque
(); for (char c = 'a'; c <= 'z'; c++) { collection.add(c); } System.out.print("Characters : "); System.out.print("["); Iterator
iterator = collection.iterator(); //will return the iterator for all characters while (iterator.hasNext()) { System.out.print(iterator.next()+" ,"); } System.out.println("]"); } }
Output