• Vector was introduced in  first version of java . that's the reason only vector is legacy class.
  • ArrayList was introduced in java version1.2, as part of java collections framework.
  • Synchronization and Thread-Safe:
  • Vector is  synchronized. Synchronization and thread safe means at a time only one thread can access the code .In Vector class all the methods are synchronized .That's why the Vector object is already synchronized when it is created .
  • ArrayList is not synchronized.

How To Make ArrayList synchronized:

  • We have direct method in collections class to make Arrraylist as Synchronized.
  • List li=new ArrayList();
  • Collections.synchrinizedlist(li);

Automatic Increase in Capacity:
  • A Vector defaults to doubling size of its array.
  • ArrayList increases it's size by 50%.
Performance:
  • Vector is slower than ArrayaList.
  • ArrayList is faster than Vector.




Instance Of Java

We will help you in learning.Please leave your comments and suggestions in comment section. if you any doubts please use search box provided right side. Search there for answers thank you.
«
Next
Newer Post
»
Previous
Older Post

1 comments for Difference between arraylist and vector

  1. Automatic Increase in Capacity:

    A Vector defaults to doubling size of its array.
    ArrayList increases it's size by 50%.
    Please ellaborate this differenc more.

    ReplyDelete

Select Menu