Java ConcurrentHashMap contains() 方法

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

ConcurrentHashMap 类的 contains() 方法测试此表中是否某些键映射到指定的值。

语法

参数

value - 要搜索的值。

返回值

如果此表中某些键根据 equals 方法映射到 value 参数,则返回 true;否则返回 false。

抛出

NullPointerException

示例 1

输出

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

示例 2

输出

Mappings are: {Delhi=100, Keral=400, Noida=200, Mumbai=300}
is c  present? ::  false