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.

collections

This is a discussion on collections within the Java forums, part of the Software Development category; what is the diff b/w vector and arraylist? which one is preferable to use?any new adv of the above?...

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 05-14-2007
Junior Member
 
Join Date: May 2007
Posts: 2
Thanks: 1
Thanked 1 Time in 1 Post
balumanickamM.tech is on a distinguished road
collections

what is the diff b/w vector and arraylist?
which one is preferable to use?any new adv of the above?
Reply With Quote
The Following User Says Thank You to balumanickamM.tech For This Useful Post:
Sponsored Links
  #2 (permalink)  
Old 05-26-2007
Junior Member
 
Join Date: May 2007
Location: Hyderabad
Posts: 10
Thanks: 0
Thanked 2 Times in 2 Posts
swapnamarri is on a distinguished road
Re: collections

Quote:
Originally Posted by balumanickamM.tech View Post
what is the diff b/w vector and arraylist?
which one is preferable to use?any new adv of the above?
1.Arraylist is not synchronized while vector is.
2. Arraylist has no default size while vector has a default size of 10.
3. Arraylist don't define any increment size while vector does.

Methods in Vector are synchronised which means they are thread-safe and thus preclude access to the Vector elements by concurrent threads.But this imposes additional overhead on the JVM as it has to acquire and release locks on the vector objects under consideration.

This is not possible in ArrayList since those methods are not synchronised and hence are faster in performance.

Use Vector only if it will be accessed by multiple threads at a time else ArrayList is always better.
Reply With Quote
The Following User Says Thank You to swapnamarri For This Useful Post:
  #3 (permalink)  
Old 05-26-2007
Junior Member
 
Join Date: Dec 2006
Location: chennai
Posts: 13
Thanks: 4
Thanked 3 Times in 3 Posts
daisy_deepa is on a distinguished road
Re: collections

which is Better?
Depends on the requirement only we can able to choose the either Vector / ArrayList

Differences :
--------------
1.Synchrnonization:
-------------------
Vector is Synchronised.ArrayList is Unsynchronised
2.Data Growth:
----------------
Both Vector and ArrayList are Dynamic arrays.
Vector : doubling the size of its array
ArrayList : 50% increase its array size
3.Element Addition & Removal:
-------------------------------
Both Vector & ArrayList are good for adding & removing the element at the end.But if it comes to other positions boh are cost effective.So that time we have to search for better container like LinkedList.
Reply With Quote
The Following User Says Thank You to daisy_deepa For This Useful Post:
  #4 (permalink)  
Old 05-28-2007
Junior Member
 
Join Date: May 2007
Location: kolkata
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
pulak is on a distinguished road
Re:hi

dear all,
i am new member of this forum.

thanks
pulak
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


Similar Threads

Thread Thread Starter Forum Replies Last Post
Media Resizer quickly and easily prepares your image collections to be published on t JobHelper Geeks Lounge 0 04-16-2007 05:40 AM


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


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