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 are the different ways to handle exceptions?

542


What is the meaning of I ++ in java?

609


What is the latest java version?

563


What is the difference between preemptive scheduling and time slicing?

595


Can we force the garbage collection to run?

540






Which is faster set or list in java?

533


How do you create a sop?

533


What are the restrictions imposed by a Security Manager on Applets?.

2070


What is t in generics in java?

565


explain different ways of using thread? : Java thread

576


Why pass by reference is not possible in java?

501


Describe the Big-O Notation.

619


Explain the polymorphism principle?

586


How is a variable stored in memory?

533


Why java is object oriented?

592