List of usage examples for java.util Iterator next
E next();
From source file:Main.java
public static void main(String[] args) { Date d1 = new Date(); Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, 22);/*w w w . j av a 2 s.c o m*/ Date d2 = cal.getTime(); Iterator<Date> i = new DateIterator(d1, d2); while (i.hasNext()) { Date date = i.next(); System.out.println(date); } }
From source file:Main.java
public static void main(String[] args) { Map<String, Charset> charsets = Charset.availableCharsets(); Iterator<Charset> iterator = charsets.values().iterator(); while (iterator.hasNext()) { Charset cs = (Charset) iterator.next(); System.out.println(cs.displayName()); if (cs.isRegistered()) { System.out.print(" (registered): "); } else {/* w w w .j a v a 2 s. c o m*/ System.out.print(" (unregistered): "); } } }
From source file:MainClass.java
public static void main(String args[]) throws Exception { Hashtable hash = new Hashtable(89); hash.put("one", "two"); hash.put("two", "three"); hash.put("three", "four"); hash.put("four", "five"); System.out.println(hash);/*w w w. j a v a 2 s.c o m*/ System.out.println(hash.size()); Enumeration e = hash.keys(); while (e.hasMoreElements()) { String key = (String) e.nextElement(); System.out.println(key + " : " + hash.get(key)); } Set set = hash.entrySet(); Iterator it = set.iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); System.out.println(entry.getKey() + " : " + entry.getValue()); } }
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> treeone = new TreeSet<Integer>(); TreeSet<Integer> treetwo = new TreeSet<Integer>(); treeone.add(12);//from ww w .j a va 2 s . c om treeone.add(13); treeone.add(14); treetwo.add(15); treetwo.add(16); treetwo.add(17); // adding treetwo to treeone treeone.addAll(treetwo); Iterator<Integer> iterator = treeone.iterator(); while (iterator.hasNext()) { System.out.print(iterator.next()); } }
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> treeadd = new TreeSet<Integer>(); treeadd.add(1);/* w w w .j av a 2 s .co m*/ treeadd.add(13); treeadd.add(17); treeadd.add(2); // create descending iterator Iterator<Integer> iterator = treeadd.descendingIterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } }
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> tree = new TreeSet<Integer>(); tree.add(12);/*from ww w . jav a2 s . c om*/ tree.add(13); tree.add(14); tree.add(15); tree.add(16); tree.add(17); // getting values less than 15 TreeSet<Integer> treeheadset = (TreeSet) tree.headSet(15); Iterator<Integer> iterator = treeheadset.iterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } }
From source file:SyncTest.java
public static void main(String args[]) { Set simpsons = new HashSet(); simpsons.add("Bart"); simpsons.add("Hugo"); simpsons.add("Lisa"); simpsons.add("Marge"); simpsons.add("Homer"); simpsons.add("Maggie"); simpsons.add("Roy"); simpsons = Collections.synchronizedSet(simpsons); synchronized (simpsons) { Iterator iter = simpsons.iterator(); while (iter.hasNext()) { System.out.println(iter.next()); }/*from w w w .j a va 2s . c om*/ } Map map = Collections.synchronizedMap(new HashMap(89)); Set set = map.entrySet(); synchronized (map) { Iterator iter = set.iterator(); while (iter.hasNext()) { System.out.println(iter.next()); } } }
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> treeadd = new TreeSet<Integer>(); treeadd.add(1);//from w ww.j a v a 2 s. com treeadd.add(2); treeadd.add(3); treeadd.add(4); treeadd.add(5); treeadd.add(6); treeadd.add(7); treeadd.add(8); TreeSet<Integer> treesubset = (TreeSet<Integer>) treeadd.subSet(3, 7); Iterator<Integer> iterator = treesubset.iterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } }
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> treeadd = new TreeSet<Integer>(); treeadd.add(1);/*from ww w .j a va 2s .c o m*/ treeadd.add(2); treeadd.add(3); treeadd.add(4); treeadd.add(5); treeadd.add(6); treeadd.add(7); treeadd.add(8); TreeSet<Integer> treesubset = (TreeSet<Integer>) treeadd.subSet(3, true, 7, true); Iterator<Integer> iterator = treesubset.iterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } }
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> treeadd = new TreeSet<Integer>(); treeadd.add(1);/* w w w . j av a 2s. co m*/ treeadd.add(2); treeadd.add(3); treeadd.add(4); treeadd.add(5); treeadd.add(6); treeadd.add(7); treeadd.add(8); TreeSet<Integer> treetailset = (TreeSet<Integer>) treeadd.tailSet(4); Iterator<Integer> iterator = treetailset.iterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } }