3:13 pm - Saturday December 16, 8226

Check whether a given key is available in LinkedHashMap boolean

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

BACK

                                          The method public boolean containsKey(Object key) returns true if the map contains the mappings of the specified key. If there is no mappings for the specified key,it returns false.

Example Program


import java.util.LinkedHashMap;

import java.util.LinkedHashMap;

public class LinkedHashMapKeySet 

{
	public static void main(String[] args) 

      {
		LinkedHashMap lhm = new LinkedHashMap();

		lhm.put("1", "Add");

		lhm.put("2", "Sub");

		lhm.put("3", "Mul");

		boolean exists = lhm.containsKey("2");

		System.out.println(" Is'2'exists in LinkedHashMap  : " + exists);

		boolean exists1 = lhm.containsKey("4");

		System.out.println("Is '4' exists in LinkedHashMap:" + exists1);

	}

}



Output Program

        Is’2’exists in LinkedHashMap  : true

         Is ‘4’ exists in LinkedHashMap:false

BACK

 

 

 

Filed in: Java Examples

Comments are closed.