什么关键是最好的HashMap?我应该使用什么键为HashMap?
我只用了十进制,每个键都是以前的++,但这只是我的想法,我不知道它是否有效。
我读到了hashCode,这个值通常用于散列表,但人们说不要滥用hashCode()作为关键字。
等待您的答案和资源链接。 这里的代码片段:
Identifier identifier = new Identifier();
identifier.setName(getString(currentToken));
identifier.setLine(currentLineNumber);
int key = identifier.hashCode();
tableOfIdentifiers.put(key, identifier);
为什么不直接使用标识符?引入哈希映射的原因是什么? – aioobe 2015-03-31 09:08:02
为什么你使用散列码作为地图中的键?请注意,散列码通常不是唯一的,所以这可能会导致问题。 – Jesper 2015-03-31 09:32:02