iterator using for loop in java code example
Example 1: java loop through arraylist
ArrayList namesList = new ArrayList(Arrays.asList( "alex", "brian", "charles") );
for(String name : namesList)
{
System.out.println(name);
}
Example 2: iterate a list using iterator
Iterator crunchifyIterator = crunchifyList.iterator();
while (crunchifyIterator.hasNext()) {
System.out.println(crunchifyIterator.next());
}