LoginSignup
8
7

More than 5 years have passed since last update.

【Java】HashMapとHashtableの違い

Posted at

調べた備忘。

HashMapとHashtableの違いは複数箇所存在するようだ。

  1. Hashtablesynchronizedであることにたいして、HashMapはそうではない。単一スレッドのケースではHashMapの方が良いパフォーマンスを出す。
  2. Hashtablenullのkey/valueを受けつけない。対してHashMapnullkeyを一つ持てるし、valueとしてはnullをいくらでも持つことができる。
  3. HashMapのサブクラスであるLinkedHashMapを使いたいときにHashMapであれば置き換えが容易だが、Hashtableでは面倒。

synchronizationが重要でないケースは、HashMapを使用した方が便利であることが多い。

[Differences between HashMap and Hashtable?

](http://stackoverflow.com/questions/40471/differences-between-hashmap-and-hashtable) ですべて議論されているので参考にする。

8
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
7