How to extract HashMap values?

Answer Posted / srikanth

package com.sri;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class entry {

public static void main(String[] args) {
try{
HashMap<Integer,Integer>tm=new
HashMap<Integer,Integer>();
tm.put(100,200);
tm.put(200,101);
tm.put(600,700);
tm.put(700,103);
tm.put(900,104);
Set s=tm.entrySet();
Iterator it=s.iterator();
while(it.hasNext()){
Map.Entry me=(Map.Entry)it.next();
System.out.println(me.getKey()
+"......"+me.getValue());
}
}catch(Exception e){
e.printStackTrace();
}
}

}


Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How large is a boolean?

653


What happens if I remove static from main method?

634


What is the nested interface?

691


Write a java program to generate fibonacci series ?

677


Mention a package that is used for linked list class in java.

624






List some features of the abstract class.

683


What is the base class of all exception classes in java?

667


What is the final blank variable?

683


What is the static method?

649


What is use of super keyword in java?

690


Explain the features of interfaces in java?

645


Where is jre installed?

678


How can constructor chaining be done by using the super keyword?

711


What is a arraylist in java?

655


What is regex used for?

635