-
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
-
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.
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks