Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How to extract HashMap values?

Answers were Sorted based on User's Feedback



How to extract HashMap values?..

Answer / siddpany

class hashMap
{
public static void main(String args[])
{
HashMap map = new HashMap();
map.put("key1",200);
map.put("key1",100);
map.put("key1",400);
map.put("key1",700);
Set set = map.keySet();
//for each loop
for(Object object :set)
{
System.out.println(map.get(Object));
}

Is This Answer Correct ?    11 Yes 4 No

How to extract HashMap values?..

Answer / 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

How to extract HashMap values?..

Answer / prakash

By using Iterator interface and by using enhanced for
loop(for each for loop).

Is This Answer Correct ?    2 Yes 0 No

How to extract HashMap values?..

Answer / 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

How to extract HashMap values?..

Answer / prachi

By using Map interface in-built funtions either keySet() or entrySet().

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is the difference between a scrollbar and a scrollpane?

0 Answers  


Can you inherit from an abstract class java?

0 Answers  


If try block is successfully executed, Then Is Finally block executed?

0 Answers   PUCIT,


What is a nested class?

0 Answers  


In the below example, how many string objects are created?

0 Answers  


What is a file pointer?

0 Answers  


Where we write javascript code in html page?

0 Answers  


how to crate clint-server socket?

1 Answers   Accenture, Infosys, Infotech, TCS,


What is binary search in java?

0 Answers  


Explain java coding standards for methods?

0 Answers  


What is the purpose of garbage collection in java? When is it used?

0 Answers  


what is difference Between Core Java and advance java

60 Answers   HCL, HP, Sambalpur University, TCS, Vensai Technologies, Wipro,


Categories