Set: iterator() : Set « java.util « Java by API






Set: iterator()

 
/*
 Output:

I
P
G
E

 * */

import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class MainClass {
  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());
    }
  }
}
           
         
  








Related examples in the same category

1.Set: add(String e)
2.Set: addAll(Collection c)
3.Set: clear()
4.Set: clone()
5.Set: contains(Object o)
6.Set: containsAll(Collection c)
7.Set: equals(Object o)
8.Set: isEmpty()
9.Set: remove(Object o)
10.Set: removeAll(Collection c)
11.Set: retainAll(Collection c)
12.Set: size()
13.Set: toArray()
14.Set: toArray(String[] a)