freakster,
I don't think it really matters, so use whichever you prefer.
Having said that I think I'd go for an array.
And BTW ArrayList is considered "the default" collection... I'd use it over a vector unless I had a compelling reason to do otherwise, like backwards compatibility with an existing library or something.
Keith.
> i have my own object (great, in'st it?). I need a
> list of this object.
>
> The list changes every 5-10min.
> When it changes, everything changes.
>
> Question: would array or vector be better?
my own guess (and that's what it truly is), is that an ArrayList would be better unless you are worried about thready type things such as concurrency and synchronization, then go with vector. Anyone -- please correct if any errors.
thnx
> unless you are worried about thready type things such as concurrency and
> synchronization
The ArrayList API documentation suggests using Collections.synchronizedList() to get a synchronised list.
One place a Vector might be useful is if a JList is being used to display the list, as these things can be constructed using a Vector as the basis of their model.
Another List implementation is the LinkedList. ArrayList implements RandomAccess, while LinkedList implements Queue. Performance differences are considered here: http://java.sun.com/developer/JDCTechTips/2002/tt0910.html
I ran into this problem:
MyObject[] MyObjects = new MyObject[text.getItemCount()];
for (int i = 0; i < MyObjects.length; i++)
{
MyObjects[i] = new MyObject();
MyObjects[i].Load(Name, text.getItem(i)); // performs a procedure on my object, i get error here.
}
Nullpointerexception... What did i forget?
btw
- text (a list-textfile) was successfully loaded.
- when MyObject is created with hand the procedure Load works.
> I ran into this problem:
> MyObject[] MyObjects = new
> MyObject[text.getItemCount()];
> for (int i = 0; i < MyObjects.length; i++)
> {
> MyObjects[i] = new MyObject();
> MyObjects[i].Load(Name, text.getItem(i)); //
> // performs a procedure on my object, i get error
> here.
> }
>
> Nullpointerexception... What did i forget?
>
> btw
> - text (a list-textfile) was successfully loaded.
> - when MyObject is created with hand the procedure
> Load works.
Looks like time to put a bunch of System.out.println() statements in. I'd pay particular attention to what text and what text.getItem(i) are at the time of the loop.