• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Vector vs Arraylist

 
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,
I know that an ArrayList will outperform a Vector in most cases. However i would like to know the Exact situations when this happens. Here i have several situations, please let me know which amoung these 2 (Vector and ArrayList) is good in these situations.
1. When there is a lot of Random insertions and deletions
2. When Deletion and additions happen at one end of the list
3. When we only traverse through the list in an ordered way
4. When we traverese in an unordered fashion
5. When the list ourgrows the initial capacity
Thanks,
Sajee
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I suggest you look at the source code for both classes for the particular Java version you are using.
It is provided in the SDK.
Bill
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Vector and ArrayList are actually very similar. The only differences I remember are that Vector is synchronized and that they have different growing behaviour.
Most of your questions are more interesting for ArrayList vs. LinkedList. The JavaDoc should be able to answer most of them, though.
 
And when my army is complete, I will rule the world! But, for now, I'm going to be happy with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic