HashMap
作为util包中比较常用的一个数据结构,充分理解内部代码的逻辑是有很必要的,这里做一个对HashMap
的containsKey
函数的源码分析笔记。
containsKey
的代码如下:
/**
* Returns <tt>true</tt> if this map contains a mapping for the
* specified key.
*
* @param key The key whose presence in this map is to be tested
* @return <tt>true</tt> if this map contains a mapping for the specified
* key.
*/
public boolean containsKey(Object key) {
return getEntry(key) != null;
}
内部调用的是getEntry
函数,进入getEntry
函