The Java program creates a HashMap named stu with integer keys and string values. It then checks whether the value "Joes" is present in the HashMap using the containsValue method. If the value is present, it prints "Value 'Joes' is contained in 'stu' HashMap", otherwise, it prints "Value 'Joes' is not contained in 'stu' HashMap".
import java.util.*; public class Specified_ValueNot { public static void main(String[] args) { HashMap <Integer,String> stu = new HashMap <>(); stu.put(101, "Kim"); stu.put(102, "Arun"); stu.put(103, "Deepika"); stu.put(105, "Joes"); stu.put(107, "John"); stu.put(108, "Vijay"); if (stu.containsValue("Joes")) { System.out.println("Value 'Joes' is contained in 'stu' HashMap"); } else { System.out.println("Value 'Joes' is not contained in 'stu' HashMap"); } } }
Value 'Joes' is contained in 'stu' HashMap
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions