Vector

Vector

  • The underlying data structure is resizable or growable Array.
  • Insertion order is preserve.
  • Duplicate objects are allow.
  • Null insertion is possible.
  • Hetrogenious objects are allow.
  • Vector class implements Serializable, Clonable & RandomAccess interface.
  • Best suitable for frequent operation is retrieval.
  • Worst  choice is frequent operation is insertion or deletion on middle.
  • Every method present in Vector class is Synchronized. Hence vector object is thread safe.
Different between ArrayList and Vector:-
ArrayList
Vector
  • no method is synchronized 
  • ArrayList objects is not thread safe
  • performance is high
  • introduced in 1.2 version and hence non legacy

 

 

  • All  method is synchronized 
  • vector objects is always thread safe
  • performance is low
  • introduced in 1.0 version and hence vector is legacy

 

 

 

 

Leave a Reply