map.put("测试",1)
map.put("测试2",2)
System.out.println(map.get("测试2"))
map.put("测试2",3)
System.out.println(map.get("测试2"))
输出结果是 : 2
3
1、用Object remove(Object key)方法从HashMap或者HashTable中移去待修改的key值对,该方法同时会返回该Key所对应的Object2、用put(Object key, Object value) 将新的Key-Value重新放入HashMap(HashTable)
static String[] s1={"E","F","G","S","T","(",")","+","-","*","/","i","#"}HashMap<String,List<String>>hashMap=new HashMap<String,List<String>>()
for(int i=5i<s1.lengthi++){
List list=new ArrayList()
list.add(s1[i])
hashMap.put(s1[i],list)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)