Example usage for java.util Iterator next

List of usage examples for java.util Iterator next

Introduction

In this page you can find the example usage for java.util Iterator next.

Prototype

E next();

Source Link

Document

Returns the next element in the iteration.

Usage

From source file:Main.java

public static void main(String args[]) {
    Vector<String> v = new Vector<String>();
    v.add("A");//from   w  ww .j  a  va 2  s.co m
    v.add("B");

    Iterator i = v.iterator();
    while (i.hasNext()) {
        System.out.println(i.next());
    }
}

From source file:MainClass.java

public static void main(String[] args) {
    List cats = new ArrayList();
    for (int i = 0; i < 7; i++)
        cats.add(new Cat(i));
    Iterator e = cats.iterator();
    while (e.hasNext())
        ((Cat) e.next()).id();
}

From source file:Main.java

public static void main(String[] a) {
    Collection<String> c = new ArrayList<String>();
    c.add("1");//from   ww  w .  j  a v  a 2s  .  co  m
    c.add("2");
    c.add("3");
    Iterator i = c.iterator();
    while (i.hasNext()) {
        System.out.println(i.next());
    }
}

From source file:MainClass.java

public static void main(String[] a) {
    Collection c = new ArrayList();
    c.add("1");/* w ww  .j  av a2s. c  om*/
    c.add("2");
    c.add("3");
    Iterator i = c.iterator();
    while (i.hasNext()) {
        System.out.println(i.next());
    }
}

From source file:MainClass.java

public static void main(String args[]) {
    List list = new ArrayList(Arrays.asList("a", "b", "c"));
    Iterator i = list.iterator();
    while (i.hasNext()) {
        System.out.println(i.next());
        list.add("Add");
    }/*from  ww w .  j av  a 2s  .co m*/
}

From source file:Iterate.java

public static void main(String args[]) {
    String elements[] = { "Irish Setter", "Poodle", "English Setter", "Gordon Setter", "Pug" };
    Set set = new HashSet(Arrays.asList(elements));
    Iterator iter = set.iterator();
    while (iter.hasNext()) {
        System.out.println(iter.next());
    }/*from   ww w.  j  a va2s. c o m*/
}

From source file:MainClass.java

public static void main(String[] a) {
    ArrayList<String> nums = new ArrayList<String>();
    nums.add("O");
    nums.add("Two");
    nums.add("Three");
    nums.add("Four");

    String s;/*from  ww w.j  av  a2s . c o m*/
    Iterator e = nums.iterator();
    while (e.hasNext()) {
        s = (String) e.next();
        System.out.println(s);
    }
}

From source file:Main.java

public static void main(String[] args) {
    List list = Collections.nCopies(5, "A");
    Iterator itr = list.iterator();
    while (itr.hasNext())
        System.out.println(itr.next());
}

From source file:Main.java

public static void main(String args[]) {
    AbstractList<String> v = new Vector<String>();
    v.add("A");/*  w w  w . j  a v a  2 s. com*/
    v.add("B");

    Iterator i = v.listIterator();
    while (i.hasNext()) {
        System.out.println(i.next());
    }
}

From source file:Main.java

public static void main(String args[]) {
    String elements[] = { "I", "P", "E", "G", "P" };
    Set set = new HashSet(Arrays.asList(elements));
    Iterator iter = set.iterator();
    while (iter.hasNext()) {
        System.out.println(iter.next());
    }/*from ww  w . j ava2s. com*/
}