This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

what is difference between ArrayList and Vector  RSS feed

 
Prashant Neginahal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
what is the difference between ArrayList and Vector in terms of performance and its storage.
Thanks.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as storage is concerned, they are the same since both use a backing Object array.
As for performance, all methods of the Vector class are synchronized, those of the ArrayList class are not. The ArrayList implementation is therefore better in terms of execution speed since accessing threads need not get the monitor prior to accessing the collection. The Vector class should not be used anymore since it is possible to get a synchronized ArrayList (when needed) by invoking Collections.synchronizedList().
 
Prashant Neginahal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Valentin Crettaz !!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!