java.util.Hashtable.containsKey(Object key)方法实例
2013-12-17 07:30
561 查看
http://www.yiibai.com/java/util/ashtable_containskey.html
The containsKey(Object key) method is used to test if the specified object is a key in this hashtable.
Following is the declaration for java.util.Hashtable.containsKey() method.
key--This is the a key to be searched.
The method call returns true if and only if the specified object is a key in this hashtable.
NullPointerException--This is thrown if the key is null.
以下例子将告诉你如何使用 java.util.Hashtable.containsKey()
Let us compile and run the above program, this will produce the following result.
描述
The containsKey(Object key) method is used to test if the specified object is a key in this hashtable.
声明
Following is the declaration for java.util.Hashtable.containsKey() method.public boolean containsKey(Object key)
参数
key--This is the a key to be searched.
返回值
The method call returns true if and only if the specified object is a key in this hashtable.
异常
NullPointerException--This is thrown if the key is null.以下例子将告诉你如何使用 java.util.Hashtable.containsKey()
package yiibai.com; import java.util.*; public class HashTableDemo { public static void main(String args[]) { // create hash table Hashtable htable = new Hashtable(); // put values into the table htable.put(1, "A"); htable.put(2, "B"); htable.put(3, "C"); htable.put(4, "D"); // check if table contains key "3" boolean isavailable=htable.containsKey(3); // display search result System.out.println("Hash table contains key '3': "+isavailable); } }
Let us compile and run the above program, this will produce the following result.
Hash table contains key '3': true
相关文章推荐
- java.util.Random.nextBoolean()方法实例
- java.util.HashMap.remove()方法实例
- java.util.Properties.getProperty()方法实例
- java.util.Collections.synchronizedSet()方法实例
- java.util.Collections.unmodifiableList()方法实例
- java.util.Random.nextInt(int n)方法实例
- java.util.Date.getTime()方法实例
- java.util.Collections.addAll()方法实例 ¥ 我要打赏
- java.util.Collections.unmodifiableList()方法实例
- java.util.ResourceBundle.getBundle()方法实例
- java.util.Collections.max()方法实例
- java.util.Collections.synchronizedMap()方法实例
- 生成随机数方法:java.util.Random.nextInt(int n)方法实例
- java.util.Collections.reverseOrder()方法实例
- java.util.ArrayList.toArray(T[]) 方法实例
- java.util.Properties.getProperty()方法实例
- Java.util.Calendar.add()方法实例
- java.util.TreeMap.headMap()方法实例
- java.util.Calendar.getTime()方法实例
- java.util.ArrayList.add(int index, E elemen)方法实例