If you really need to do this, you can call iterator() to get an iteration over Map.Entry objects, and look at the value() in each Map.Entry until you find the value of interest, and then look at the key(). This is obviously quite inefficient if you need to do it multiple times; in that case, consider keeping two maps, one in each "direction."
I can not figure it out, can you show me a sample?
HashMap hm = new HashMap(); hm.put("java1","NetBean"); hm.put("java2","Eclipse"); hm.put("java3","JBuilder"); hm.put("java4","JDeveloper"); Can you retrieve String "java4" if you know the mapping object "Jdeveloper" only?
Here's semi-psuedocode for Ernest's suggestion. It returns the first key that it finds mapped to the given value.Map.Entry is an inner class of Map and contains a single pairing (key and value). Note that some Maps allow null values.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad: