Solved

Colloection choice, which one is best for my problem

Posted on 2006-10-27
3
174 Views
Last Modified: 2012-05-05
I have been studing the collection material I could find on the webulator, My problem is as follows;

1, Class a (customers) containd a Cust_ID String and a customer name.
2, Class b (SalesOrder) contains details of sales orders including Cust_ID which has a one to many relationship with class a

I would like to create a data structure which contains both sets of data with class a as the key and class b as the
value(s).

I would like to be able to retrieve multiple instances of class b dependant on a value of class a.  I also want that class b is retrieved in a particular sequence (Document number)

I have looked at MAPs   but they want unique values.

I do not want anyone to write the code ,just a nudge in the right direction, I'm thinking TreeSets. Examples of code pertaining to nudging however will not be frowned upon.
0
Comment
Question by:ajackson99
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 17820473
You need

Map<ClassA, List<ClassB>>;
0
 
LVL 14

Expert Comment

by:hoomanv
ID: 17820874
> I also want that class b is retrieved in a particular sequence (Document number)
Use TreeSet or PriorityQueue for bs
0
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 17823415
i'd go with:

Map<A, TreeSet<B>>;

make B implement Comparable ordering by doc number

http://java.sun.com/docs/books/tutorial/collections/index.html
http://javaalmanac.com/egs/java.util/coll_SortSet.html
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
jboss wildfly 10.1 10 405
Which non-HTML GUI front end to use with Java? 3 51
Chrome and Firefox Java 5 67
Github api to fetch the number of collaborators in a git repo 1 25
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question