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

  • Re: application.match and multidimensional array?
    ... I'm using several arrays in code; the smaller array keeps a subset ... latter would end up including every element from the source array. ... I'm going through up to 10 iterations where in each case I'm ... know who I listed as my friends, in which case I'll only check to see who I ...
    (microsoft.public.excel.programming)
  • Re: string in an array
    ... The variable named 'array' is a *POINTER*, ... with malloc() or friends calloc() or reallocis to remember how ...
    (comp.lang.c.moderated)
  • Re: change color in a bmp image
    ... columns of the array but it changes other pixels as well apart from ... Well, as shown above, "the Matlab way" is to use array indexing and ... probably need it to look at ind2sub and friends. ...
    (comp.soft-sys.matlab)
  • Re: change color in a bmp image
    ... columns of the array but it changes other pixels as well apart from ... Well, as shown above, "the Matlab way" is to use array indexing and ... probably need it to look at ind2sub and friends. ...
    (comp.soft-sys.matlab)
  • Re: Why the address of array equals array.
    ... Rahul wrote: ... of the array. ... Nit-picking is best done among friends. ...
    (comp.lang.c)