HashMap 과 Hashtable의 차이

Posted by epicdev Archive : 2011. 9. 21. 03:06
출처: http://stackoverflow.com/questions/40471/java-hashmap-vs-hashtable

 There are several differences between HashMap and Hashtable in Java:
  1. Hashtable is synchronized, whereas HashMap is not. This makes HashMap better for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones.
  2. Hashtable does not allow null keys or values. HashMap allows one null key and any number of null values.
  3. One of HashMap's subclasses is LinkedHashMap, so in the event that you'd want predictable iteration order (which is insertion order by default), you could easily swap out the HashMap for a LinkedHashMap. This wouldn't be as easy if you were using Hashtable.

'Archive' 카테고리의 다른 글

표준 Java 코드 스타일  (0) 2011.09.21
Static 메소드에서 Synchronized 사용하는 방법  (0) 2011.09.21
Fail-Fast란?  (0) 2011.09.21
안드로이드에서의 Multithreading 예제  (0) 2011.09.21
Java Heap에 대한 10가지 사항  (0) 2011.09.20