HashTable 순회 방법
Hashtable<String, String> hashtable = new Hashtable<String, String>(); hashtable.put("1", "a"); hashtable.put("2", "b"); hashtable.put("3", "c"); hashtable.put("4", "d"); Enumeration<String> enumKey = hashtable.keys(); while(enumKey.hasMoreElements()){ String key = enumKey.nextElement(); String value = hashtable.get(key); System.out.println(value); } | cs |
HashMap<String, String> hashmap = new HashMap<String, String>(); hashmap.put("1", "a"); hashmap.put("2", "b"); hashmap.put("3", "c"); hashmap.put("4", "d"); for(Entry<String, String> entry : hashmap.entrySet()){ String key = entry.getKey(); String value = entry.getValue(); System.out.println(key + " - " + value); } | cs |