Re: Using arrays of objects ?



TonyB <tonyb@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I'm new to java, and would like some advice on how to keep track of groups
of objects where the number of objects is not predefined.

java.util.Collection and friends make this pretty easy.

I could keep a reference to each tool object as added in an array of type
tool but an array is declared with a fixed length, so short of defining the
array to have a some arbitrary large size I can't see how to deal with this
list of objects. I don't want to use a database at this time.

ArrayList<Tool> is the most common way to do this. Depending on your needs,
you may prefer a HashSet, TreeSet, LinkedList, or some other Collection that
fits your performance and usage requirements.
--
Mark Rafn dagon@xxxxxxxxx <http://www.dagon.net/>
.



Relevant Pages