List of usage examples for java.util Iterator next
E next();
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()); System.out.println(cs.toString()); }/*from w w w . j a v a 2 s . co m*/ }
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()); System.out.println(cs.name()); }//from w w w. j a va2 s . c om }
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()); System.out.println(cs.canEncode()); }/* w ww . j a v a 2 s . co m*/ }
From source file:Main.java
public static void main(String[] args) throws IOException { String fileContent = "s1=1\n" + "s2=Main\n" + "s3=Fri Jan 31 00:00:00 IST 3913"; InputStream propStream = new StringBufferInputStream(fileContent); PropertyResourceBundle bundle = new Main(propStream); // Get resource key set Set keySet = bundle.handleKeySet(); Iterator keys = keySet.iterator(); while (keys.hasNext()) { System.out.println("Bundle key: " + keys.next()); }//from www . j av a2s . c o m }
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> treeadd = new TreeSet<Integer>(); treeadd.add(1);//from www . j a va2s. com treeadd.add(3); treeadd.add(17); treeadd.add(2); System.out.println("Last element is: " + treeadd.pollLast()); Iterator<Integer> iterator = treeadd.iterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } }
From source file:Main.java
public static void main(String[] args) { Map errors = new HashMap(); errors.put("404", "A."); errors.put("403", "B."); errors.put("500", "C."); String errorDesc = (String) errors.get("404"); System.out.println("Error 404: " + errorDesc); Iterator iterator = errors.keySet().iterator(); while (iterator.hasNext()) { String key = (String) iterator.next(); System.out.println("Error " + key + " means " + errors.get(key)); }//w w w .j a va 2 s. com }
From source file:Main.java
public static void main(String[] args) { TreeSet<Integer> treeadd = new TreeSet<Integer>(); treeadd.add(1);//from www.jav a 2s.com treeadd.add(3); treeadd.add(17); treeadd.add(2); System.out.println("First element is: " + treeadd.pollFirst()); Iterator<Integer> iterator = treeadd.iterator(); while (iterator.hasNext()) { System.out.println(iterator.next()); } }
From source file:MainClass.java
public static void main(String args[]) { Hashtable<String, Double> balance = new Hashtable<String, Double>(); String str;/*from w w w . j a v a 2s .c o m*/ double bal; balance.put("A", 4.34); balance.put("B", 3.22); balance.put("C", 8.00); balance.put("D", 9.22); balance.put("E", -9.08); Set<String> set = balance.keySet(); Iterator<String> itr = set.iterator(); while (itr.hasNext()) { str = itr.next(); System.out.println(str + ": " + balance.get(str)); } System.out.println(); bal = balance.get("A"); balance.put("A", bal + 1000); System.out.println("A's new balance: " + balance.get("A")); }
From source file:ArrayListGenericDemo.java
public static void main(String[] args) { ArrayList<String> data = new ArrayList<String>(); data.add("hello"); data.add("goodbye"); // data.add(new Date()); This won't compile! Iterator<String> it = data.iterator(); while (it.hasNext()) { String s = it.next(); System.out.println(s);/*w ww . j av a2 s. c om*/ } }
From source file:SetDemo.java
public static void main(String[] args) { String[] letters = { "A", "B", "C", "D", "E" }; Set s = new HashSet(); for (int i = 0; i < letters.length; i++) s.add(letters[i]);/*from w w w .j av a 2 s. c om*/ if (!s.add(letters[0])) System.out.println("Cannot add a duplicate.\n"); Iterator iter = s.iterator(); while (iter.hasNext()) System.out.println(iter.next()); System.out.println(""); SortedSet ss = new TreeSet(); for (int i = 0; i < letters.length; i++) ss.add(letters[i]); if (!ss.add(letters[0])) System.out.println("Cannot add a duplicate.\n"); iter = ss.iterator(); while (iter.hasNext()) System.out.println(iter.next()); }