Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ArrayList vs. Vector

 
Wickes Potgieter
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to come up with a good explination for my choices.txt and would appreciate some comments.
In my DBAdapter class, I have a method which returns a list of contractors but am not sure if I should return the list as an ArrayList or Vector. Which will be the best to use...? and why?
Both have dynamic sizing capabilities, but Vectors are synchronized...
Thank you in advance...
 
Hanna Habashy
Ranch Hand
Posts: 532
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Wickes:
Sun documentation refers to ArrayList, HashMap, and HashSet as being the preferred "primary implementations". Their overall performance is better, and you should use them unless you need a special feature provided by another implementation. In general, Vector is slower because all of its methods are sync. Regular array are lighter wieght than any other collection class. If you find arrays fit your needs, you should consider them first, otherwise you should looke for the appropriate collection calss.
[ May 10, 2004: Message edited by: Hanna Habashy ]
 
Wickes Potgieter
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your response!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic