List of usage examples for java.util Iterator next
E 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"); Set set = map.entrySet();//from ww w.j a v a2 s .c o m Iterator iter = set.iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.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"); Set set = map.entrySet();/*from w w w . j a v a 2 s. co m*/ Iterator iter = set.iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); System.out.println(entry.getKey() + " -- " + entry.getValue()); } }
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"); Set st = lHashMap.keySet();/*from w w w . j ava 2s.c o m*/ Iterator itr = st.iterator(); while (itr.hasNext()) { System.out.println(itr.next()); } st.remove("2"); boolean blnExists = lHashMap.containsKey("2"); System.out.println(blnExists); }
From source file:MainClass.java
public static void main(String[] args) { Provider provider = Security.getProvider("BC"); Iterator it = provider.keySet().iterator(); while (it.hasNext()) { String entry = (String) it.next(); if (entry.startsWith("Alg.Alias.")) { entry = entry.substring("Alg.Alias.".length()); }/*from ww w . j a v a2 s .c om*/ System.out.println(entry); } }
From source file:Main.java
public static void main(String[] args) { String[] coins = { "A", "B", "C", "D", "E" }; List src = new LinkedList(); for (int i = 0; i < coins.length; i++) { src.add(coins[i]);/* w ww. j av a 2 s. com*/ } System.out.println(src); Collections.fill(src, "java2s.com"); Iterator liter = src.listIterator(); while (liter.hasNext()) System.out.println(liter.next()); }
From source file:MainClass.java
public static void main(String[] a) { Map map = new HashMap(); map.put("key1", "value1"); map.put("key2", "value2"); map.put("key3", "value3"); Set set = map.entrySet();//from www. j a v a2 s .c o m Iterator iter = set.iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); System.out.println(entry.getKey() + " -- " + entry.getValue()); } }
From source file:MainClass.java
public static void main(String[] args) throws Exception { Document doc = new SAXBuilder().build("books.xml"); Element books = doc.getRootElement(); Iterator it = books.getChildren().iterator(); while (it.hasNext()) { Element book = (Element) it.next(); System.out.println(book.getChildText("name") + " was published in " + book.getChildText("pubDate")); }//from ww w.ja v a 2s. c o m }
From source file:Main.java
public static void main(String[] args) { String text = "A,B,C,D"; String[] keyValue = text.split(","); Map<Integer, String> myMap = new HashMap<Integer, String>(); for (int i = 0; i < keyValue.length; i++) { myMap.put(i, keyValue[i]);/*from ww w .j a v a2 s . com*/ } Set keys = myMap.keySet(); Iterator itr = keys.iterator(); while (itr.hasNext()) { Integer key = (Integer) itr.next(); String value = (String) myMap.get(key); System.out.println(key + " - " + value); } }
From source file:HTDemo2.java
public static void main(String args[]) { Hashtable<String, Double> balance = new Hashtable<String, Double>(); String str;// ww w . j av a2s . c om double bal; balance.put("A", 3434.34); balance.put("B", 123.22); balance.put("C", 1378.00); balance.put("D", 99.22); balance.put("E", -19.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:MainClass.java
public static void main(String[] a) { Properties props = System.getProperties(); Iterator iter = props.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); System.out.println(entry.getKey() + " -- " + entry.getValue()); }//from w w w . j a v a 2s . c o m }