Only 48 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!



  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Vector vs Arraylist  RSS feed

 
Sajee Joseph
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • 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
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • 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
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!