Search a key in hashtable
We can use containsKey() method to search a key in hashtable. Syntax: hashtable.containsKey(specifiedKey); Example: package com.w3schools; import java.util.Hashtable; public class Test { public static void main(String args[]){ //Create Hashtable object. Hashtable<String, String> hashtable = new Hashtable<String, String>(); //Add objects to the Hashtable. hashtable.put("1", "Jai"); hashtable.put("2", "Mahesh"); hashtable.put("3","Vivek"); System.out.println(hashtable); if(hashtable.containsKey("2")){ System.out.println("The Hashtable contains key … Read more