Hashmap Problem

Hi All,I have created a Hashmap with 3 valuesmap.put(1,value1);map.put(2,value2);map.put(3,value3);Now I want to fetch VALUE of Key "2" with KEY of "value1"Thanks.
[226 byte] By [JavaNewUsera] at [2007-11-27 4:06:24]
# 1
What?You want to call map.get(1) and get value2 back? Did I hear that right?
puckstopper31a at 2007-7-12 9:11:30 > top of Java-index,Java Essentials,Java Programming...
# 2
seems the hasmap is the wrong structure for what you want to do X)
calvino_inda at 2007-7-12 9:11:30 > top of Java-index,Java Essentials,Java Programming...
# 3
Yeah, and I want the head of Amy Winehouse on the body of Scarlett Johansen.
DrLaszloJamfa at 2007-7-12 9:11:30 > top of Java-index,Java Essentials,Java Programming...
# 4

OK,

Let me start again,

I am creating a hashmap dynamically and need to pass two parameter to a function

1st parameter :- is the Value of the latest put in Hashmap.

2nd parameter :- is the Key of the previous Value.

If we see the example again I have

{KEY1,VALUE1}

{KEY2,VALUE2}

{KEY3,VALUE3}

SO, I want to call

function(VALUE2,KEY1)

If Hashmap is not the correct choice , then could you please let me know the best option.

Thanks.

JavaNewUsera at 2007-7-12 9:11:30 > top of Java-index,Java Essentials,Java Programming...
# 5

why don't you just store the items into "temporary" objects

like:

// let's say we have Object latestValue and keyOfPreviousValue

map.put(key, value);

latestValue = value;

function(latestValue, keyOfPreviousValue);

keyOfPreviousValue = key;

notice that latestValue is not necessary with such a structure

calvino_inda at 2007-7-12 9:11:30 > top of Java-index,Java Essentials,Java Programming...
# 6

> Yeah, and I want the head of Amy Winehouse on the body of Scarlett Johansen.

I forced that out for the sake of analogy. Scarlett has the face of an angel on the body of a stripper.

[url #" style="display: block; background-image: url('http://bksc.dyndns.org/Homer_Simpson.jpg'); width: 80px; height: 80px] [/url]

DrLaszloJamfa at 2007-7-12 9:11:30 > top of Java-index,Java Essentials,Java Programming...
# 7

> Hi All,

>

>I have created a Hashmap with 3 values

>map.put(1,value1);

> map.put(2,value2);

>map.put(3,value3);

> I want to fetch VALUE of Key "2" with KEY

> of "value1"

>

> Thanks.

Why, may I ask, would you want this?

What (in a slightly larger scope) are you trying to accomplish?

xiarcela at 2007-7-12 9:11:30 > top of Java-index,Java Essentials,Java Programming...
# 8
Got the solutionThanks.
JavaNewUsera at 2007-7-12 9:11:30 > top of Java-index,Java Essentials,Java Programming...