Example usage for java.util Iterator hasNext

List of usage examples for java.util Iterator hasNext

Introduction

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

Prototype

boolean hasNext();

Source Link

Document

Returns true if the iteration has more elements.

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  v a 2 s.c  o m*/
    v.add("B");

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

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());
    }/*  w w  w . j a v  a 2 s .com*/
}

From source file:Main.java

public static void main(String[] a) {
    Collection<String> c = new ArrayList<String>();
    c.add("1");/* w ww . j  ava  2 s .  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[] a) {
    Collection c = new ArrayList();
    c.add("1");/*www .j a  v a  2s. c  o 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 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 w  w  w . j  a va  2  s  .  c  om
}

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.jav a 2  s  . c om
}

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());
    }//from ww  w  .  j  a  v  a  2  s.c om
}

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  ww .  j  a va  2 s.com
    v.add("B");

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

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());
    }//ww  w.java2 s.  c o m

}