如果你存的是某些变量值如String之类,你就得重新添加,
如果是别有特定属性的Object,如自定的class,可以直接取出修改其相关属性值

解决方案 »

  1.   

    See part of the source codes of java.util.Hashtable below:...    public synchronized Object put(Object key, Object value) {
    // Make sure the value is not null
    if (value == null) {
        throw new NullPointerException();
    } // Makes sure the key is not already in the hashtable.
    Entry tab[] = table;
    int hash = key.hashCode();
    int index = (hash & 0x7FFFFFFF) % tab.length;
    for (Entry e = tab[index] ; e != null ; e = e.next) {
        if ((e.hash == hash) && e.key.equals(key)) {
    Object old = e.value;
    e.value = value; //* modify old value with ease ;]
    return old;
        }
    } modCount++;
    if (count >= threshold) {
        // Rehash the table if the threshold is exceeded
        rehash();            tab = table;
                index = (hash & 0x7FFFFFFF) % tab.length;
    }  // Creates the new entry.
    Entry e = new Entry(hash, key, value, tab[index]);
    tab[index] = e;
    count++;
    return null;
        }...So, why not do it directly?