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。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。