The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
February 2001

Advertisement

Advertisement
where you can ask and answer Java programming questions.">
artima.com - a resource for Java and Jini developers
Artima | Search | Java | Design | JVM | Jini | Books | Seminars | Subscribe 


Java Answers Forum
February 2001

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Re: hashtables

Posted by Kishori Sharan on February 01, 2001 at 11:16 PM

There are two ways to do this using hashtable
1) Use a character in a string as key and then the number as a string in value and again back
key value
"a" "12"
"b" "13"
"c" "14"
"12" "a"
"13" "b"
"14" "c"

This way given a number you can get its coded character and given a character you can get its code by just using get method of hashmap. Of course, you need to convert the number and string back to int and character ..
2) In this case just maintain one set i.e from chars to ints in string form and then to get the number given a char just use get method of hashmap and then to get the char given a number use iterator or any other method you feel may serve the purpose.

Thanx
Kishori



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us