【发布时间】:2010-10-04 12:08:58
【问题描述】:
Set<String> tempSet = new HashSet<String>();
for (Map.Entry<String, String> entry : map.entrySet()) {
String orginalKeys = entry.getKey();
System.out.println(orginalKeys);
String newKey = orginalKeys.replace('.','/');
if (!newKey.equals(orginalKeys)) {
map.put(newKey, entry.getValue());
tempSet.add(orginalKeys);
map.remove(orginalKeys);
}
}
System.out.println(map);
这仅替换了一个键,但我想用上述事件替换所有键。我要做什么错了?
【问题讨论】:
-
您的代码缺少右大括号。
-
@Reddy,不再是了,Andreas 已经修复了它。
-
@Colin - 这次他问为什么 他的 解决方案不起作用。这是一个后续问题,而不是重复的 IMO。
-
@Stephen C,我的错,我认为这是完全相同的问题。
标签: java