List of usage examples for java.util Iterator hasNext
boolean hasNext();
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()); }//w ww .jav a2s . co 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()); }// ww w . j av a 2 s . 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 w ww . j a v a 2 s . com*/ }
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 ww w. ja v a 2s . co m*/ }
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 w ww .ja v a2s. c om }
From source file:Main.java
public static void main(String args[]) { PriorityQueue<Integer> prq = new PriorityQueue<Integer>(); for (int i = 0; i < 10; i++) { prq.add(i);//from ww w. ja va 2 s. c o m } // create iterator from the queue Iterator it = prq.iterator(); while (it.hasNext()) { System.out.println("Value: " + it.next()); } }
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 ww . j a va2 s . 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("3", "Three"); treeMap.put("2", "Two"); Set st = treeMap.keySet();//from w w w . java 2 s . c om Iterator itr = st.iterator(); while (itr.hasNext()) { System.out.println(itr.next()); } st.remove("1"); System.out.println(treeMap.containsKey("1")); }
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 www .j a va 2 s . co m*/ }