Solved

How to use a nested TreeMap

Posted on 2003-11-25
6
513 Views
Last Modified: 2006-11-17
Hi,

I have data in the following form: Library Case Study example

String borrower, Object loanstate, Object loanitem.

I have many borrowers, loanstate is either borrowed or returned and the loanitem
would be say a bookitem.

What I would like to do is output in the form:

Borrower:      Borrowed       Book1
                              Book2
                              Book3
                              ..etc
               Returned       Book1
                              Book3

I thought maybe a nested TreeMap would allow me to do this i.e.

Key, (key, value)

borrower (loanstate, loanitem) would allow me to do this.

Any suggestions on how to code this up ?

Thanks

Drew
0
Comment
Question by:DrewAllan
[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
  • 2
  • 2
6 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 9817812
Your Borrower should be one entity. It should have a list of Books. One of the fields of Book should be loan state. The way you organise the collection of books is up to you. It could be a TreeMap keyed on the book's UID (ISBN)
0
 

Author Comment

by:DrewAllan
ID: 9817868
Can you give me an example of how to code it ?

Thanks
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 9817886
Sorry - no. This is clearly class work and as such, it's against the Member Agreement to do this. We can certainly help with code you have already produced.
0
 

Author Comment

by:DrewAllan
ID: 9830355
Ok I can appreciate that but it was more an example of how to constuct it I was after.

How me suggesting an example of how to construct the Nested TreeMap

would it be

Map(index,[indexOuter,[[indexInner1, [value1, value2,... ],[indexInner22, [value22, value23,... ], [indexInner3, [value31, value32,... ],[indexInner4, [value42, value43,... ]..etc])

where index would be string object called Borrower and the outer nest value [index,[values]] would be say an ArrayList and then the inner nest values would be another ArrayList.

Do you think this would work or would there be a better way of doing it?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
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:

691 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