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...

In the HashMap, we know the values but we dont know the key,
then how can we get the key from HashMap ?????

Answer Posted / ganesh

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

public class MapEntrySetDemo {

public static void main(String[] argv) {

Map map = new HashMap();

map.put("Adobe", "Mountain View, CA");
map.put("IBM", "Mountain View, CA");
map.put("Learning Tree", "Los Angeles, CA");
map.put("Microsoft", "Redmond, WA");
map.put("Netscape", "Mountain View, CA");
map.put("O'Reilly", "Sebastopol, CA");
map.put("Sun", "Mountain View, CA");

Set entries = map.entrySet();
Iterator it = entries.iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
if("Mountain View, CA".equals(entry.getValue()))
{
System.out.println(entry.getKey() );

}
}
}
}

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Give few examples of final classes defined in Java API?

1121


How to do encapsulation in java?

1009


What is the implementation of destroy method in java. Is it native or java code?

908


How is final different from finally and finalize?

869


Is sizeof a preprocessor?

951


Is array a class in java?

931


What is time complexity algorithm?

996


What are the restriction imposed on a static method or a static block of code?

1006


Can we have more than one package statement in source file ?

976


What do you understand by the term singleton?

945


Can a static method be final?

1013


What are controls and their different types in awt?

1029


When can you say a graph to be a tree?

1035


Explain jvm, jre, and jdk?

962


What is the difference between an if statement and a switch statement?

1107