Home > Programming, Technology > Difference between java.util.Vector and java.util.ArrayList

Difference between java.util.Vector and java.util.ArrayList


Both java.util.Vector and java.util.ArrayList use the Array inside them and they are dynamically re-sizable.  By Default Vector doubles its size when the size of it grows its threshold where as in case of ArrayList its size is increased by half of its size.

The main difference between java.util.Vector and java.util.ArrayList is that, All the operations of vectors are synchronized, But, The methods of ArrayList are not. If you have applications which require Thread Safety then use the Vectors otherwise use ArrayList.

The syncronized methods of Vector will have some performance overhead and costlier than the normal operation of ArrayList.

Advertisements
  1. September 27, 2012 at 4:39 am

    One more difference between ArrayList vs Vector is that later is a legacy class and initially not part of Collection API

  1. November 12, 2010 at 7:01 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: