Hash table based implementation of the Map interface. This implementation provides all of the optional map operations, and permits null values and the null key. (The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls.) This class makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time.

解决方案 »

  1.   

    接口一致,主要区别在于同步上
    Hashmap算是轻量的,如无同步要求,选用Hashmap效率要高。
      

  2.   

    我不都没用过Hashmap
    但是我觉得HashTable很好用。
      

  3.   

    请问,wangwenyou(王文友)1。什么是同步?2。轻量和重量的区别?3。为什么HashMap的效率高,高在哪里?回答上来才是高手!
      

  4.   

    1、出于并发性的考虑,同步保证多个进程不会同时修改一个对象,可以说,它是一种“锁”。
    2、轻量这个词多用于微软的ActiveX,也许用在这并不恰当,但我只是想表达效率高、存储消耗小的意思。
    3、在多个进程同时访问HashMap,并且其中一个进程修改了HashMap的内容:如删除添加项目时,不会在其它的进程中体现出来;而HashTable则不同。去除同步,它不需要“排队”;不检测更新,它效率自然要高。
    另外,回答出这问题,我也不算高手。