Its me again
I need to know the differences between an ArrayList and a Vector.
Whoever knows, plz provide the answer
FG
Printable View
Its me again
I need to know the differences between an ArrayList and a Vector.
Whoever knows, plz provide the answer
FG
Whether to use whether array list or vector depends on the situation ad factors. Sometimes Vector is better; sometimes ArrayList is better. But some of the following factors can be considered for usage decision like API, Synchronization, Data growth,usage patterns
Some of the differences between an ArrayList and a Vector are Arraylist has no default size while vector has a default size, Arraylist don't define any increment size while vector does. But there is lot more which I am not aware. Hope somebody would throw highlight on this discussion.
Thanks timmy and fred
Going by reply, It is evident a Vector is more efficient than an Arraylist.
Bottomline is we need to choose either a Vector or an Arraylist based on the merits of the scenario - Right?
Based of the usage the choice of arraylist or vector differs. I have added some more points to which can be considered while making choice between vector list and array. They are namely Vectors are synchronized. Any method that touches the Vector's contents is threading safe. Array List, on the other hand, is unsynchronized, making them, therefore, not thread safe. So if you don't need a thread-safe collection, use the Array List. If you don't know how much data you'll have, but you do know the rate at which it grows, Vector does possess a slight advantage since you can set the increment value.
how ever its always good to go for ArrayList, if you are using java1.5 in sense of performance.If you want to make it as threadsafe, u can do that at any time using
collections.synchronizedList(arrayList) ;
or we have some more methods in java.util.concurrent package,which we can use.