Easy Hastable Question

Hi, I'm new to Jave, and programming in general so excuse me for asking a simple question.

I have a Hashtable on a client server which I have to extract the email address given a name, and the name given an email address.

//Set up hash table with test data

emails = new Hashtable();

emails.put("Ince","ince@hotmail.com");

emails.put("Roberts","roberts@hotmail.com");

emails.put("Timms","timms2@yahoo.com");

emails.put("Rowlands","Rowlands@tiny.com");

emails.put("Eustace","Eustace@yahoo.com");

emails.put("Lord","Lord3@hotmail.com");

String staffName="";

String staffEmail="";

........

I can use the following code to get the email address staffEmail given the name staffName;

staffEmail = (String)emails.get(staffName);

But don't know how to get the reverse and obtain the name given the email?

I'm sure it's a really simple question so please help me if you can!!!

Thanks

[986 byte] By [Ruddersa] at [2007-11-27 8:33:51]
# 1
Either you maintain a pair of maps, or you use something like a BidiMap: http://jakarta.apache.org/commons/collections/api-release/org/apache/commons/collections/BidiMap.htmlThere is no class in the J2SE that solves your problem right out of the box.
Hippolytea at 2007-7-12 20:29:59 > top of Java-index,Java Essentials,Java Programming...
# 2
Thanks, I'll take a look
Ruddersa at 2007-7-12 20:29:59 > top of Java-index,Java Essentials,Java Programming...