Geeks Talk

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.

An ArrayList and a Vector

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...

Go Back   Geeks Talk > Software Development > Java
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

Java Java related Issues and Problems

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-19-2006
Junior Member
 
Join Date: May 2006
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
FantaGuy is on a distinguished road
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
Reply With Quote
The Following User Says Thank You to FantaGuy For This Useful Post:
Sponsored Links
  #2 (permalink)  
Old 06-22-2006
Contributing Member
 
Join Date: May 2006
Posts: 84
Thanks: 0
Thanked 11 Times in 7 Posts
timmy is on a distinguished road
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
Reply With Quote
  #3 (permalink)  
Old 06-22-2006
Contributing Member
 
Join Date: May 2006
Posts: 79
Thanks: 0
Thanked 6 Times in 5 Posts
fred is on a distinguished road
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.
Reply With Quote
  #4 (permalink)  
Old 06-23-2006
Junior Member
 
Join Date: May 2006
Posts: 7
Thanks: 0
Thanked 1 Time in 1 Post
FantaGuy is on a distinguished road
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?
Reply With Quote
  #5 (permalink)  
Old 06-24-2006
Contributing Member
 
Join Date: May 2006
Posts: 88
Thanks: 0
Thanked 10 Times in 9 Posts
norman is on a distinguished road
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.
Reply With Quote
The Following User Says Thank You to norman For This Useful Post:
  #6 (permalink)  
Old 03-19-2009
Junior Member
 
Join Date: Mar 2009
Location: hyderbad
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
kalyan3214 is on a distinguished road
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.
Reply With Quote
Reply

  Geeks Talk > Software Development > Java

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 03:12 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved