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) {
    TreeSet<Integer> tSet = new TreeSet<Integer>();

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

    Iterator itr = tSet.iterator();

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

From source file:Main.java

public static void main(String[] args) {

    Path path = Paths.get("C:", "tutorial/Java/JavaFX", "Topic.txt");

    Iterator<Path> it = path.iterator();

    while (it.hasNext()) {
        System.out.println(it.next());
    }/*from   www.ja v  a 2  s.  co m*/
}

From source file:Main.java

public static void main(String[] args) {
    LinkedHashMap<String, String> lHashMap = new LinkedHashMap<String, String>();

    lHashMap.put("1", "One");
    lHashMap.put("2", "Two");
    lHashMap.put("3", "Three");

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

    while (itr.hasNext()) {
        System.out.println(itr.next());
    }/*from   w ww  .  j  a v  a2 s.c o  m*/
}

From source file:Main.java

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

    Collection c = hMap.values();
    Iterator itr = c.iterator();
    while (itr.hasNext()) {
        System.out.println(itr.next());
    }//from w  w w  .ja v a  2 s . co  m
}

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("3", "Three");
    treeMap.put("2", "Two");

    Set st = treeMap.keySet();//from   www .ja va 2s .  c  o m
    Iterator itr = st.iterator();
    while (itr.hasNext()) {
        System.out.println(itr.next());
    }
    st.remove("1");

    System.out.println(treeMap.containsKey("1"));
}

From source file:Main.java

public static void main(String[] a) {
    HashMap<String, String> map = new HashMap<String, String>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");

    Collection set = map.values();
    Iterator iter = set.iterator();

    while (iter.hasNext()) {
        System.out.println(iter.next());
    }//from  ww  w  .  ja  va2 s. co  m
}

From source file:Main.java

public static void main(String[] a) {
    Map<String, String> map = new HashMap<String, String>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    map.put("key3", "value3");

    Collection set = map.values();
    Iterator iter = set.iterator();

    while (iter.hasNext()) {
        System.out.println(iter.next());
    }//from  w w  w . jav  a2  s.  c  o  m
}

From source file:Main.java

public static void main(String[] args) {
    LinkedHashSet<Integer> lhashSet = new LinkedHashSet<Integer>();

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

    Iterator itr = lhashSet.iterator();

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

From source file:Main.java

public static void main(String args[]) {
    LinkedList<String> ll = new LinkedList<String>();

    ll.add("A");/*from w w  w  .j  a v a2  s. c o m*/
    ll.add("ja v a2s.com");
    ll.addLast("B");
    ll.add("C");

    Iterator<String> itr = ll.iterator();
    while (itr.hasNext()) {
        String element = itr.next();
        System.out.print(element + " ");
    }
}

From source file:Main.java

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

    Iterator itr = arrayList.iterator();
    while (itr.hasNext()) {
        System.out.println(itr.next());
    }//from w  ww.j  a  v a  2 s .c  om
}