Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on An ArrayList and a Vector within the Java forums, part of the Software Development category; Its me again I need to know the differences between an ArrayList and a Vector. Whoever knows, plz provide the answer FG...
|
|||||||
|
|||
|
An ArrayList and a Vector
Its me again
I need to know the differences between an ArrayList and a Vector. Whoever knows, plz provide the answer FG |
| The Following User Says Thank You to FantaGuy For This Useful Post: | ||
| Sponsored Links |
|
|||
|
Re: An ArrayList and a Vector
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
|
|
|||
|
Re: An ArrayList and a Vector
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.
|
|
|||
|
Re: An ArrayList and a Vector
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? |
|
|||
|
Re: An ArrayList and a Vector
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.
|
| The Following User Says Thank You to norman For This Useful Post: | ||
|
|||
|
Re: An ArrayList and a Vector
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. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|