当前位置: 技术问答>java相关
请问哪个方法可以检查Map中有某个键存在?
来源: 互联网 发布时间:2017-03-09
本文导语: 谢谢 | Map.containsKey(Object key) Returns true if this map contains a mapping for the specified key 试验一下这个方法 | java.util Interface Map containsKey public boolean containsKey(Object key) Retu...
谢谢
|
Map.containsKey(Object key)
Returns true if this map contains a mapping for the specified key
试验一下这个方法
Returns true if this map contains a mapping for the specified key
试验一下这个方法
|
java.util
Interface Map
containsKey
public boolean containsKey(Object key)
Returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains at a mapping for a key k such that (key==null ? k==null : key.equals(k)). (There can be at most one such mapping.)
Parameters:
key - key whose presence in this map is to be tested.
Returns:
true if this map contains a mapping for the specified key.
Throws:
ClassCastException - if the key is of an inappropriate type for this map (optional).
NullPointerException - if the key is null and this map does not not permit null keys (optional).
Interface Map
containsKey
public boolean containsKey(Object key)
Returns true if this map contains a mapping for the specified key. More formally, returns true if and only if this map contains at a mapping for a key k such that (key==null ? k==null : key.equals(k)). (There can be at most one such mapping.)
Parameters:
key - key whose presence in this map is to be tested.
Returns:
true if this map contains a mapping for the specified key.
Throws:
ClassCastException - if the key is of an inappropriate type for this map (optional).
NullPointerException - if the key is null and this map does not not permit null keys (optional).