do*****@kc.rr.com skrev:
I am working on a program that accepts data from a web form like this:
Parm Value
Doug Doug
Doug_age 40
Doug_phone 111-222-3333
Kelly Kelly
Kelly_age 42
Kelly_phone 222-333-4444
Basically I get the persons name then an _ and then the parm name. If
I don't get the _ I know that it is the name.
There is more data like address, email, ect.... I would like to store
this data in an array and then eventually insert it into a dataabse.
What I want to do is build an array that holds this data, but has an
"index" by name.
For example:
MyData[Doug][age] = 40;
MyData[Doug][phone] = 111-222-3333;
MyData[Kelly][age] = 42;
MyData[Kelly][phone] = 222-333-4444;
Anyone have an idea how I would go about this?
Thanks,
Doug
Write a class for holding a person's data and store the person-objects
in a HashMap with the name as key (- is the first name really always
unique in your app?). (Use a LinkedHashMap if you want order preserved.)
If you really, really want an array, you could of course map names to
indices (in a HashMap). The get-operation is placed in a method like
getIndx(), and this is called where an index is needed:
MyData[getIndx(Doug)][age]. /ulf