Java List iterate using Iterator

Description

Java List iterate using Iterator


import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class Main {
  public static void main(String args[]) {
    List<String> langList = new ArrayList<>();
    langList.add("CSS");
    langList.add("Java");
    langList.add("Javascript");
    langList.add("SQL");
    langList.add("C++");
    langList.add("HTML");

    Iterator<String> it = langList.iterator();
    while (it.hasNext()) {
      System.out.println(it.next());
    }// w w  w.  j a va2  s  . c  o  m

  }
}



PreviousNext

Related