Create an object with the name passed in as a string argument to a method

Hi,

I am sorry if it's too trivial for this forum , but I am stuck with the following requirements.

I have a method

void abc(String object_name, String key, String value)

method abc should first check if there exists in memory a hashmap object with the name passed in as argument object_name.

If yes ..just put the key and value there.

if not , then create the hashmap object called <object_name> and insert the key/value there.

Can anybody help me in the first step i.e, how to check if an object exists with the name passed in and if not then create it.

Will getInstance method be of any help?

Thanks in advance for your response.

-Sub-java

[716 byte] By [sub-javaa] at [2007-11-27 10:38:27]
# 1

It can't be done as you describe. Objects don't have names.

What you can do is create a Map whose keys are these names and whose values are other Maps.

jverda at 2007-7-28 18:54:33 > top of Java-index,Java Essentials,Java Programming...
# 2

Thanks for your input :)

sub-javaa at 2007-7-28 18:54:33 > top of Java-index,Java Essentials,Java Programming...
# 3

not only it can't be done, it shouldn't be done. Most time I see newbies ask this it is because they have a poor understanding of what variables, objects and references are.

petes1234a at 2007-7-28 18:54:33 > top of Java-index,Java Essentials,Java Programming...