【发布时间】:2015-03-20 08:55:50
【问题描述】:
我有一个hashmap<String, String>,其中包含大约一千个条目。
现在我必须以不能在课堂外修改的方式公开它。所以我写了像
public static Map<String, String> getResponseCodeSource()
{
return Collections.unmodifiableMap(codeMsgMap);
}
这个方法被非常频繁地调用。我的问题是
1。这会导致性能问题吗?
2.方法 (unmodifiableMap) 是否在 Map 上进行迭代,或者这将以 O(constant) 复杂性执行其活动?
【问题讨论】:
标签: java collections hashmap