Find key present in HashMap






import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;

public class HashMapKey {

     
public static void main(String[] args) {


HashMap  mapa =new  HashMap();
             
                 mapa.put("a", "Mukesh");
                 mapa.put("b",  "deoghar");
                 mapa.put("c",  "satsang");
                 mapa.put("d", "devsang");
                 
                   Set  se=new HashSet();
                  
       System.out.println("Keys of map" +mapa);  
   
   System.out.println("Keys of map" +mapa.keySet());
        
   System.out.print("Is c present?:" +mapa.containsKey("c"));
     
     
      }

}

 When  run  this   code  out will like this --


Keys of map{a=Mukesh, b=deoghar, c=satsang, d=devsang}
Keys of map[a, b, c, d]
Is c present?:true

Find key present in HashMap  Find key  present in HashMap Reviewed by Mukesh Jha on 7:42 AM Rating: 5

No comments:

Add your comment

All Right Reserved To Mukesh Jha.. Theme images by Jason Morrow. Powered by Blogger.