HashMap Key and Values
This java code is simple explains how HashMap store the key and values. how to
to get the key and values of the HashMap.
import java.util.*;
public class Hashmapdetails {
public static void main(String args[]) {
Map map =new HashMap() ;
map.put("westbangal" , "kolkotta");
map.put("bhihar", "patna");
map.put("bhihar","patnaa");
map.put("jharkhand", "Ranchi");
Set set= map.entrySet();
System.out.println(set);
System.out.println(map.get("bhihar"));
System.out.println(map.values());
System.out.println(map.keySet());
}
}
you can see duplicate key and watch out the output of the program .
[westbangal=kolkotta, jharkhand=Ranchi, bhihar=patnaa]
patnaa
[kolkotta, Ranchi, patnaa]
[westbangal, jharkhand, bhihar]
HashMap Key and Values
Reviewed by Mukesh Jha
on
2:55 AM
Rating:
No comments:
Add your comment