aspose file tools*
The moose likes Beginning Java and the fly likes What type of Collection should  use? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "What type of Collection should  use?" Watch "What type of Collection should  use?" New topic
Author

What type of Collection should use?

Martin Vietor
Ranch Hand

Joined: Oct 31, 2008
Posts: 40
Hello,

I have a simple question. I am writing a program that will help me set up plans for workshifts. The people who do the actual working tell me what days they can or cannot work (stored long with some other stuff in WishListType wishlist), I put that into a csv file, the file is read and then the computer can - from the list of people who could theoretically work that day - roll the dice to see who has to work. No problem so far.

In order for the plan to be fair, I have to make sure that everyone gets the same amount of weekdays, holidays, saturdays and so forth. What day is a holiday will (since that is very hard to explain to the program - changes every year in Germany) be part of the csv file. After the file is read I have a certain amount of wishlists an one String[] that contains what KIND of day each day of the year is. All this information is then returned to the core program, that called my LoadTheFile() class.

My question is therefore: What type of Collection or List or Set or Map or whatever should I use, when I want to store different types of objects - namely a bunch of WishListTypes and one String[]? Is there one where I don't have to say beforehand how many objects there will be (as with the ArrayList, I believe)?

Thank you, Martin


The problem people have in trying to create something foolproof is that they generally underestimate the inginuity of fools.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3838

Martin Vietor wrote:Is there one where I don't have to say beforehand how many objects there will be (as with the ArrayList, I believe)?


Yes, with implementations of List,Map,Set etc.. you don't have to specify the size beforehand.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
 
wood burning stoves
 
subject: What type of Collection should use?