How do i get the key of "tradeid3" ? Is there any inbuilt method that does it?

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


public class abcd{
    public static void main(String args[]){
    Map m= new HashMap(); 
        m.put("TRADEID1", "tradeid1");
        m.put("TRADEID2", "tradeid2");
        m.put("TRADEID3", "tradeid3");
    }
}

This might answer that for you.

You haven't given any background about data size, data volatility, key-value duplicates etc, but if it's low volatility with only one value for each unique key, I would consider two Maps, the second one having the keys and values swapped so you can retrieve the key directly from the value.
I assume you have already looked at whether you should be using a HashMap or a TreeMap? (eg do you want to print the data sorted in some order?)

either that, or let the value be an Object which has two elements: the actual value and the key. but that just sounds weird :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.