java.util.concurrent.ConcurrentSkipListMap的containsKey()方法是Java中的一个内置函数,如果指定的元素存在于此映射中,则该函数返回true布尔值,否则返回false。
用法:
public boolean containsKey(Object ob)
参数:该函数接受一个强制性参数ob,它指定要在此映射中进行测试的键。
返回值:如果此映射包含指定键的映射,则该函数返回true。
以下示例程序旨在说明上述方法:
示例1:
// Java Program Demonstrate containsKey()
// method of ConcurrentSkipListMap
import java.util.concurrent.*;
class GFG {
public static void main(String[] args)
{
// Initializing the map
ConcurrentSkipListMap<Integer, Integer>
mpp = new ConcurrentSkipListMap<Integer,
Integer>();
// Adding elements to this map
for (int i = 1; i <= 5; i++)
mpp.put(i, i);
// Checks if 9 is present in the map
if (mpp.containsKey(9))
System.out.println("9 is present"
+ " in the mpp.");
else
System.out.println("9 is not present"
+ " in the mpp.");
}
}
示例2:
// Java Program Demonstrate containsKey()
// method of ConcurrentSkipListMap
import java.util.concurrent.*;
class GFG {
public static void main(String[] args)
{
// Initializing the map
ConcurrentSkipListMap<Integer, Integer>
mpp = new ConcurrentSkipListMap<Integer,
Integer>();
// Adding elements to this map
for (int i = 1; i <= 5; i++)
mpp.put(i, i);
// Checks if 4 is present in the map
if (mpp.containsKey(4))
System.out.println("4 is present"
+ " in the mpp.");
else
System.out.println("4 is not present"
+ " in the mpp.");
}
}
相关用法
- Java ConcurrentSkipListMap put()用法及代码示例
- Java ConcurrentSkipListMap equals()用法及代码示例
- Java ConcurrentSkipListMap remove()用法及代码示例
- Java ConcurrentSkipListMap containsValue()用法及代码示例
- Java ConcurrentSkipListMap isEmpty()用法及代码示例
- Java ConcurrentSkipListMap clone()用法及代码示例
- Java ConcurrentSkipListMap size()用法及代码示例
- Java ConcurrentSkipListMap clear()用法及代码示例
- Java ConcurrentSkipListMap ceilingKey()用法及代码示例
- Java Map containsKey()用法及代码示例
- Java Properties containsKey(value)用法及代码示例
- Java AbstractMap containsKey()用法及代码示例
- Java SimpleBindings containsKey()用法及代码示例
- Java TreeMap containsKey()用法及代码示例
注:本文由纯净天空筛选整理自Twinkl Bajaj大神的英文原创作品 ConcurrentSkipListMap containsKey() method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。