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 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?...
|
|||||||
|
|||
|
collections
what is the diff b/w vector and arraylist?
which one is preferable to use?any new adv of the above? |
| The Following User Says Thank You to balumanickamM.tech For This Useful Post: | ||
| Sponsored Links |
|
|||
|
Re: collections
Quote:
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. |
| The Following User Says Thank You to swapnamarri For This Useful Post: | ||
|
|||
|
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. |
| The Following User Says Thank You to daisy_deepa For This Useful Post: | ||
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
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 |