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[] argv) throws Exception {
    SortedSet<String> set = new TreeSet<String>();
    set.add("b");
    set.add("c");
    set.add("a");

    Iterator it = set.iterator();
    while (it.hasNext()) {
        Object element = it.next();
    }/*from ww w  . jav a  2 s  . c  o m*/
    String[] array = (String[]) set.toArray(new String[set.size()]);
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {

    String elements[] = { "A", "C", "D", "G", "F" };
    Set set = new TreeSet(Arrays.asList(elements));
    Iterator iter = set.iterator();
    while (iter.hasNext()) {
        System.out.println(iter.next());
    }// w  w w. j  a va 2 s  .c o  m
}

From source file:MainClass.java

public static void main(String[] a) {

    List list = Arrays.asList(new String[] { "A", "B", "C", "D" });
    Iterator iter = list.iterator();

    while (iter.hasNext()) {
        System.out.println(iter.next());
    }/*from   w w w. j  av a  2 s  .  co m*/

}

From source file:MainClass.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    Set set = new HashSet(Arrays.asList(elements));

    Iterator iter = set.iterator();
    while (iter.hasNext()) {
        System.out.println(iter.next());
    }//from w  w  w .j a v  a 2s.com

}

From source file:Main.java

public static void main(String[] args) {
    TreeMap<String, String> treeMap = new TreeMap<String, String>();
    treeMap.put("1", "One");
    treeMap.put("2", "Two");
    treeMap.put("3", "Three");

    Collection c = treeMap.values();
    Iterator itr = c.iterator();

    while (itr.hasNext()) {
        System.out.println(itr.next());
    }//from  w w  w  .ja  v a 2 s .c  o m
}

From source file:Main.java

public static void main(String[] a) {
    String elements[] = { "A", "B", "C", "D", "E" };
    HashSet<String> set = new HashSet<String>(Arrays.asList(elements));

    Iterator iter = set.iterator();
    while (iter.hasNext()) {
        System.out.println(iter.next());
    }//from www  . j  av  a 2  s. c o m

}

From source file:Main.java

public static void main(String[] args) {

    HashSet<Integer> hSet = new HashSet<Integer>();

    hSet.add(new Integer("1"));
    hSet.add(new Integer("2"));
    hSet.add(new Integer("3"));

    Iterator itr = hSet.iterator();

    while (itr.hasNext())
        System.out.println(itr.next());
}

From source file:MainClass.java

public static void main(String args[]) {

    String[] a = new String[] { "a", "b", "c" };
    List list = Arrays.asList(a);

    Iterator i = list.iterator();
    while (i.hasNext()) {
        System.out.println(i.next());
    }/*from   w w w  . ja  va  2 s  .c o m*/
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    Map weakMap = new WeakHashMap();
    Object keyObject = "";
    Object valueObject = "";
    weakMap.put(keyObject, valueObject);

    Iterator it = weakMap.keySet().iterator();
    while (it.hasNext()) {
        Object key = it.next();
    }/*w ww  .ja va2  s.c om*/
}

From source file:Main.java

public static void main(String[] args) {
    LinkedList<String> lList = new LinkedList<String>();
    lList.add("1");
    lList.add("2");
    lList.add("3");
    lList.add("4");
    lList.add("5");

    Iterator itr = lList.iterator();
    while (itr.hasNext()) {
        System.out.println(itr.next());
    }//from   w  w  w . ja  va  2 s .  c  o  m
}