Java ConcurrentHashMap containsKey() 方法

2024 年 10 月 21 日 | 1 分钟阅读

ConcurrentHashMap 类的 containsKey() 方法测试指定的对象是否是此表中的键。

语法

参数

key - 可能的键

返回值

当且仅当指定的对象是此表中的键时返回 true,由 equals 方法确定;否则返回 false

抛出

NullPointerException

示例 1

输出

Mappings are: {python=20, c++=30, java=10, c=25, .net=15}
is java  present? ::  true

示例 2

输出

Mappings are: {python=20, c++=30, java=10, c=25, .net=15}
is javascript  present? ::  false