Vectors, LinkedList, Stacks

Vector<E>

The Vector class is a legacy class. The Vector and ArrayList classes are implemented using dynamically resizable arrays, providing fast
random access (i.e., positionbased access) and fast list traversal—very much like using an ordinary array.

Difference between ArrayList and Vector

  • Unlike the ArrayList class, the Vector class is threadsafe, meaning that concurrent calls to the vector will not compromise its integrity.
  • The ArrayList increases its array size by 50 percent if it runs out of room.A Vector defaults to doubling the size of its array if it runs out of room.
  • ArrayList has no default size, while vector has a default size of 10.
  • ArrayList can use only Iterator to access the elements. Vector list can use Iterator and Enumeration Interface to access the elements.

 

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: