检查 Java 中的 Hashtable 中是否存在值
方法 contains() 返回 true,否则返回 false.
import java.util.Hashtable;Runtime:
public class Main {
public static void main(String[] args) {
Hashtable<字符串,字符串>ht = 新哈希表<字符串,字符串>();
ht.put(1”, 一”);
ht.put(2”, 二”);
ht.put(3”, 三”);
布尔值 b = ht.contains(three”);
System.out.println(值 3 是否存在于 Hashtable 中?: ” + b);
}
}
值 3 存在于 Hashtable 中?:true