List of usage examples for java.util Set iterator
Iterator<E> iterator();
From source file:Main.java
public static void main(String[] args) { Map map = System.getenv(); Set keys = map.keySet(); Iterator iterator = keys.iterator(); while (iterator.hasNext()) { String key = (String) iterator.next(); String value = (String) map.get(key); System.out.println(key + " = " + value); }//from w w w . ja va2 s . com }
From source file:MainClass.java
public static void main(String[] s) { Hashtable table = new Hashtable(); table.put("key1", "value1"); table.put("key2", "value2"); table.put("key3", "value3"); Set set = table.entrySet(); Iterator it = set.iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); System.out.println(entry.getKey() + " : " + entry.getValue()); }//from www . j av a 2s . c o m }
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(); Iterator iter = set.iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); }/*www . ja va 2 s . c om*/ }
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"); map.put(null, null);//ww w. j a v a 2s .c o m Set set = map.keySet(); Iterator iter = set.iterator(); while (iter.hasNext()) { System.out.println(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(); Iterator iter = set.iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); System.out.println(entry.getKey() + " -- " + entry.getValue()); }//from w w w .j a va2 s .c o m }
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(); Iterator itr = st.iterator(); while (itr.hasNext()) { System.out.println(itr.next()); }//from w ww. j a va2s . c om st.remove("1"); System.out.println(treeMap.containsKey("1")); }
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(); Iterator iter = set.iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); System.out.println(entry.getKey() + " -- " + entry.getValue()); }/*from www .ja va2 s . c om*/ }
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"); Set st = hMap.keySet(); Iterator itr = st.iterator(); while (itr.hasNext()) System.out.println(itr.next()); // remove 2 from Set st.remove("2"); System.out.println(hMap.containsKey("2")); }
From source file:Iterate.java
public static void main(String args[]) { String elements[] = { "Irish Setter", "Poodle", "English Setter", "Gordon Setter", "Pug" }; Set set = new HashSet(Arrays.asList(elements)); Iterator iter = set.iterator(); while (iter.hasNext()) { System.out.println(iter.next()); }/*from w w w . j a v a 2 s. c o m*/ }
From source file:Main.java
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()); }/*from w ww .j a v a 2 s . c om*/ }