java iterator example

Java
Iterator iterator = list.iterator(); 
        System.out.println("List elements : "); 
        while (iterator.hasNext()) 
            System.out.print(iterator.next() + " ");
Source

Also in Java: