- 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();
Automatic Increase in Capacity:
- A Vector defaults to doubling size of its array.
- ArrayList increases it's size by 50%.
- Vector is slower than ArrayaList.
- ArrayList is faster than Vector.
Automatic Increase in Capacity:ReplyDelete
A Vector defaults to doubling size of its array.
ArrayList increases it's size by 50%.
Please ellaborate this differenc more.