File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes about lists Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "about lists" Watch "about lists" New topic
Author

about lists

Ran Takad
Greenhorn

Joined: Dec 02, 2005
Posts: 1
this my first post here, i hope you can help me
my question is :
i have two Arraylist one for rooms (for example) and the other for house, when i want to add a room to specific house i need to find that house in the houselist first, then i need to have internal list inside houselist to add the room to that house (house1[room1,room2,room3],house2[room1]). but i don't know how to implement a list inside a list? any idea?
thanks in advance
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
You have classes Room and House, right php php? And a house has zero or more rooms:

If you aren't using the current version of Java, that field would be defined by:

By the way, have you done the tutorial on collections: http://java.sun.com/docs/books/tutorial/collections/index.html ?


There is no emoticon for what I am feeling!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38851
    
  23
Welcome on board.

You will have to change your displayed name, because there is a strict policy about user names here.

You should find it quite easy to implement the data structure you suggest. You do exactly what you ahve suggested on screen. Just bite the bullet and go for it, and see whether it works.

I presume that as a newby you are using J2SE5.0? If so, you will want to use your ArrayLists in a generic fashion. You might have three classes:

CR
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24184
    
  34

As Campbell says, your display name doesn't satisfy our site policy. A display name needs to be a real (sounding) first name, a space, and a last name. You can change yours here. Thanks for your understanding and prompt attention.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about lists