memostack
article thumbnail
Java - HashMap과 Hashtable의 차이
Language/JAVA 2021. 3. 8. 18:27

HashMap과 Hashtable 모두 map 자료구조다. 사용 방법도 거의 동일하지만, 차이점이 있음 // HashMap Map map = new HashMap(); map.put(1, "one"); map.put(2, "two"); System.out.println(map.get(1)); // one System.out.println(map.get(2)); // two // Hashtable Map table = new Hashtable(); table.put(1, "one"); table.put(2, "two"); System.out.println(table.get(1)); // one System.out.println(table.get(2)); // two HashMap HashMap은 동기화를 ..