Using Map and Lists. Simple


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Using Map and Lists. Simple

  1. #1
    Join Date
    Sep 2003
    Posts
    24

    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

  2. #2
    Join Date
    Mar 2004
    Posts
    635
    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.

  3. #3
    Join Date
    Nov 2004
    Location
    Norway
    Posts
    1,560
    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.
    eschew obfuscation

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center