Groovy containsKey()方法
2018-12-29 15:49 更新
此映射是否包含此键?
句法
boolean containsKey(Object key)
参数
键 - 用于搜索的键。
返回值
True或false,取决于键值是否存在。
例子
下面是一个使用这个方法的例子 -
class Example {
static void main(String[] args) {
def mp = ["TopicName" : "Maps", "TopicDescription" : "Methods in Maps"]
println(mp.containsKey("TopicName"));
println(mp.containsKey("Topic"));
}
}
当我们运行上面的程序,我们将得到以下结果 -
true false
以上内容是否对您有帮助:

免费 AI IDE


更多建议: