iterator loop java

Java
for(Iterator<String> i = String.iterator(); i.hasNext();) {
  String s = i.next();
  //do something with the string s
  System.out.println(s);
}
Source

Also in Java: