3:00 am - Friday April 19, 2019

HashMap Example program for containsValue(Object value)

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
*@author:candidjava
*@description:HashMap Example Program for containsValue(Object value)
**/

import java.util.HashMap;
public class ContainsValue
{
public static void main(String[] args)
{

/* Create object of HashMap */

HashMap<Integer, String> hm = new HashMap<Integer, String>();

/* Add value in HashMap */

hm.put(new Integer(1), "Bharat");

hm.put(new Integer(2), "Gyan");

hm.put(new Integer(4), "Vrishti");

hm.put(new Integer(3), "Sarika");

hm.put(new Integer(5), "Rohit");

hm.put(new Integer(6), "Parineeta");

/* Check values present in HashMap or not */

System.out.println("Returns :" + hm.containsValue("Vrishti"));

System.out.println("Returns :" +hm.containsValue("Ankita"));
}
}

output

Output:

Returns :true

Returns :false

Filed in: Z-A All Java Codes

Comments are closed.