Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Using Map and Lists. Simple

Hi,
My prolem is very simple, but i'm beggining with java.

I have 10 key-values: "CUSTOMER_ID" , the others are not important
What is important is that I want to have different values under the same key CUSTOMER_ID

The structure should be like this:

CUSTOMER_ID 5
CUSTOMER_ID 1
CUSTOMER_ID 4
OFFICE_ID 33
SOME_KEY 10
SOME_OTHER_KEY 123

Which structure can I use?
can I use Java Map?
List?
Other?

and how to insert this values and how to load it?
Please show me simple code
[577 byte] By [haiaw] at [2007-11-11 7:39:23]
# 1 Re: Using Map and Lists. Simple
sounds like a table to me. I think a tree would work. it would prevent redundant data. The tree would have several nodes (keys) then you can add leafs (values) to each node.
Phaelax at 2007-11-11 22:37:45 >
# 2 Re: Using Map and Lists. Simple
If you don't know what and how many "different" values you need to associate to a Customer object you should implement Customer as a class with an inner Hashtable+ArrayList to hold these values. This would require some typecasting, sorting and instanceof - coding though.
sjalle at 2007-11-11 22:38:45 >