38、HashMap 和 Hashtable 有什么区别?

  1. HashMap是线程不安全的,HashTable是线程安全的;
  2. HashMap中允许键和值为null,HashTable不允许;
  3. HashMap的默认容器是16,为2倍扩容,HashTable默认是11,为2倍+1扩容;
posted @ 2023-05-17 21:41  cnetsa  阅读(17)  评论(0编辑  收藏  举报