Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is difference between ArrayList and Vector

 
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 !!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic