What is difference between array list and vector.? and which one is most useful.? array list does whatever vector does so why we need the array list?

Showing Answers 1 - 3 of 3 Answers

Vikas J Mandal

  • Oct 30th, 2005
 

Sometimes Vector is better; sometimes ArrayList is better; sometimes you don't want to use either. I hope you weren't looking for an easy answer because the answer depends upon what you are doing.

Vector and ArrayList both can expand size if required. A Vector defaults to doubling the size of its array, while the ArrayList increases its array size by 50 percent. If you don't know how much data you'll have, but you do know the rate at which it grows, Vector does possess a slight advantage since you can set the increment value.

Basically Vector is Syncronized Array list is Not. We can make array List also as Syncronized by using :-
Collections.SyncronizedList(new ArryList())




  Was this answer useful?  Yes

Vikas J Mandal

  • Oct 30th, 2005
 

Vikas J Mandal Wrote:

Sometimes Vector is better; sometimes ArrayList is better; sometimes you don't want to use either. I hope you weren't looking for an easy answer because the answer depends upon what you are doing.

The key difference between Arrays and Vectors in Java is that Vectors are dynamically-allocated.They aren't declared to contain a type of variable; instead, each Vector contains a dynamic list of references to other objects. The Vector class is found in the java.util package, and extends java.util.Abstractlist.

The big advantage of using Vectors is that the size of the vector can change as needed.Vector and ArrayList both can expand size if required. A Vector defaults to doubling the size of its array, while the ArrayList increases its array size by 50 percent. If you don't know how much data you'll have, but you do know the rate at which it grows, Vector does possess a slight advantage since you can set the increment value.

Basically Vector is Syncronized Array list is Not. We can make array List also as Syncronized by using :-
Collections.SyncronizedList(new ArryList())

Because Vectors are dynamically-allocated, they offer a relatively memory-efficient way of handling lists whose size could change drastically.Because Vectors are dynamically-allocated, they offer a relatively memory-efficient way of handling lists whose size could change drastically.Vectors have some useful member functions that make coding simpler.Vector class is based on an array of object references, these methods are generally no more efficient than array-based algorithms.Thus, Vectors are easier to use than arrays for most applications, but they do not offer all the performance advantages of fully-dynamic storage.





  Was this answer useful?  Yes

Dhayanand darshanala

  • Nov 3rd, 2005
 

Array list are fixed and vector are growable

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions