How to extract HashMap values?

Answer Posted / qamar islam

package Qamar;
import java.util.*;




import javax.xml.crypto.dsig.spec.HMACParameterSpec;
public class HashMapExtract {




public static void main(String args[])
{
HashMap<Integer, String> hm=new HashMap<Integer, String>();
hm.put(1, "Qamar");
hm.put(2, "Gulnar");
hm.put(3, "Qamar");
hm.put(4, "Gulnar");
hm.put(51, "Qamar");
hm.put(6, "Gulnar");
Set set =hm.entrySet();

Iterator itr=set.iterator();
while(itr.hasNext())
{
System.out.println("values in hashmap: "+itr.next());
}
}
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the purpose of using the java bean?

681


Is singleton set an interval?

623


What do u mean by variable?

682


What is the benefit of inner / nested classes ?

620


What are the changes in java.io in java 8 ?

640






How do you convert int to char in java?

675


Why string is immutable with example?

624


What is the difference between equals() and == in java?

600


Why should I use abstract class?

661


What is an empty class? What functionality does it offer in Java?

809


If a class is declared without any access modifiers, where can the class be accessed?

682


Can you start a thread twice in Java?

744


What do you mean by hashing?

733


What is charat java?

616


Can we overload destructor in java?

627