比如如下,我想改key=two 的值"2-cpu",怎么改?     注意:是直接改!怎么个改法?
 HashMap hm = new HashMap();
 hm.put("one","1-cpu");
 hm.put("two","2-cpu");
 hm.put("thrid","3-cpu");

解决方案 »

  1.   

    就是直接put啊,put后没有的会被插进去,已经有的原来的就会被覆盖掉。
      

  2.   

    楼上说的对,直接向里面put就可以了
      

  3.   

    当然可以,你只要put进去一个有相同Key的Value,前一个Value就已经被覆盖了
      

  4.   

    可以的,看文档:
    public Object put(Object key,Object value)
    Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced. 
    当"映射关键字"一样的时候,新的值就会覆盖旧的值.