Difference between Vector and ArrayList in java?

java.util.Vector came along with the first version of java development kit (JDK). java.util.ArrayList was introduced in java version1.2, as part of java collections framework. As per java API, in Java 2 platform v1.2,vector has been retrofitted to implement List and vector also became a part of java collection framework.

All the methods of Vector is synchronized. But, the methods of ArrayList is not synchronized. All the new implementations of java collection framework is not synchronized.

Vector and ArrayList both uses Array internally as data structure. They are dynamically resizable. Difference is in the way they are internally resized. By default, Vector doubles the size of its array when its size is increased. But, ArrayList increases by half of its size when its size is increased.

Therefore as per Java API the only main difference is, Vector’s methods are synchronized and ArrayList’s methods are not synchronized.

Vector or ArrayList? Which is better to use in java?

In general, executing a ‘synchronized’ method results in costlier performance than a unsynchronized method. Keeping the difference in mind, using Vector will incur a performance hit than the ArrayList. But, when there is a certain need for thread-safe operation Vector needs to be used.

Is there an alternate available in java for Vector?
ArrayList can be synchronized using the java collections framework utility class and then ArrayList itself can be used in place of Vector.

When there is no need for synchronized operation and you still look for better performance ‘Array’ can be used instead of ArrayList. But the development is tedious, since it doesn’t provide user friendly methods.

When you use Vector or ArrayList, always initialize to the largest capacity that the java program will need. Since incrementing the size is a costlier operation.

This Java Collection tutorial was added on 04/06/2008.



Comments on “Difference between Vector and ArrayList in java?”

  1. Adish

    Good…Keep it up

  2. Sue

    Hi Joe,

    Your explanation is great. Wondering if you can provide more info on Java Collections Framework and when to use a particular Collection implementation.

  3. Gaurav Kumar Vij

    the diference i read it’s great

  4. Soumik

    could u just inform what is the default load factor of ArrayList and Vector

  5. Dipraj

    You are not talking about initial capacity when ArrayList or Vector gets created.

  6. Gopi

    The default size for Vector & ArrayList is 10

    • Shailendra

      This is wrong.
      Default size of arrayList and Vector is zero

      • Singha

        @shailendra you just go through the ArrayList class file. There u can that the default size of ArrayList and Vector is 10

        • Manoj

          default value of vector and arraylist is 10.

          • muniganesh

            Since jdk version 1.7.40, there is no initial capacity for the ArrayList and only the empty ArrayList will be created. You may see the documentation of arraylist with size 10 is created, but when you check its source there is only the emply list is being created and java team did not update that in their document.

  7. kapil

    hey thats great. But will u please tell me more about thread safe methods.

  8. upendra singh

    hi can you explain me how to iterate through a map
    in java.

    • Rajnish Jha

      Hi Upendra,

      Map interface does not extends Iterable interface.So we can not use iterator() method to access the elements of Map classes. However, we can get the collection-view of a map by using entrySet() method .



  9. deepak


  10. good notes on difference between vector and arraylist……

  11. siva

    excellent theory , but its good if it has programmatic explanation also for better understand….

  12. manu

    its great answer

  13. this is great answering for diffrent between ArrayList and Vector
    keep it ! up

  14. Gerald

    ArrayList has a default size?
    i came to know that only vector has it?
    can you please explain me in detail

  15. suresh

    ArrayList has a default Size is 0
    Vector has a default Size is 10

  16. jaya

    Vector is synchronized and ArrayList is not synchronized.

  17. Kumaresan

    Very nice article

  18. Usha.S

    It is very easy to UNDERSTAND,Thankyou

  19. Anonymous

    vvn vfcb

  20. Anonymous

    Thanks very good explanation……….

  21. Anonymous

    But why Vector class is synchronized?
    What is reason behind it?

  22. kumaraaswamy

    simply super understand

  23. kumaraaswamy


  24. Nikitha

    Its excellent . Exactly what I was looking for. Thank you.

  25. vitthal

    my concept is clear
    thanks for that answer

  26. Umair


    Thanks for the great work u are doing. I am just confused on the terms synchronized and non-synchronized , o could you please evaluate these two terms with reference to above article.



  27. krish

    nice explanation…

  28. krishnamoorthy.k

    good explanation and excellent work…

  29. Ramesh

    Crispy explanation

  30. superbbbbbbbbbbbbbbbbbbb.

  31. surender

    Very good explanation so i have cleared with my doubt i would like to thanks to such a great info could you tell about synchronous and non-sysnchronous methods in vector and arraylist

    warm regards
    surender reddy

  32. also explan about vector size and arraylist pls do needfull

  33. Anuj Pal

    impressive work!!

  34. siddu

    Hi joe,
    this is good but i need more deeply can u provide it ??

  35. Nandkishor

    hey you explain collection framework concept nicely….
    be continue

  36. Nandkishor

    can any one explain enum in details with example

  37. chaitu

    excellent, good , superb

  38. Swethaa

    your blog is very usefyl and informative. Your explanation is clear and very easy to understand.

  39. Latcham

    It’s Good Article.Thank You.

  40. niyati


  41. Anonymous

    Good way to understood the difference b/w them. Keep it up for good work.

  42. fayaz


  43. Abhijit

    Nice Explanation but it will add cherry on cake if u explain how vector is Synchronized and how ArrayList is not-Synchronized with An Example.And Multiple Thread can Access vector And ArrayList.

  44. Amarnath

    Your explanation is great, I am expecting discuss more in java and post this site.

  45. Anonymous

    thanks joe i think it will help me

  46. vikas pathak(jbp)

    great description……..

  47. pramod

    Why do we need Vector if we can have synchronized ArrayList? Which one is better Vector or synchronized ArrayList?

    • babji

      hi promod,
      if you need storage collection is synchronized u can use vector other wise arralist.you can use synchronize arraylist in the case you want lost with synchronize

      • sasi


        If multiple threads access an ArrayList concurrently then we must externally synchronize the block of code which modifies the list either structurally or simply modifies an element. Structural modification means addition or deletion of element(s) from the list. Setting the value of an existing element is not a structural modification.
        Only one thread can call methods on a Vector at a time, and there’s a slight overhead in acquiring the lock; if you use an ArrayList, this isn’t the case.

  48. easwer

    Hi Sir:
    can you able to give me some tips to select in the interview

  49. Anonymous

    can u please specify synchronised


    nice Explanation….

  51. Anonymous

    love you what a post , chaka maar diya ….

  52. Anil Chahal

    May u plz tell me how Vector uses thread safe methods while ArrayList uses non thread safe methods..ur rest info is very good..thanks in advance..

  53. Ranj


    Superb blog articles – read every one of them !

    One request – can you start one more subsection – Collections? I did find abt read only collections and diff bw Vector/AL, but will appreciate few more, as it is really pretty easy to grasp the topics as you pen them….

    Keep up the good work. One of the very few blogs that I like :)

  54. Suresh

    We need Some More Examples about collection..

  55. prakash

    its very useful for me…still i need some example….thank u

  56. Anonymous

    better to add some code snippets that will understand very easily.

  57. moumita

    its very useful for me…though i need some example….
    thank u

  58. Anonymous

    Hi its very nice explaination..Still can elaborate using sample coding for synchronised and unsynchronized…..

  59. Dinesh Vhatte

    Hi Joe,
    an excellent blog to explain it. arranged it very well.

  60. Anonymous

    Very nice explaination

  61. Divya

    Hi nice expalnation …
    could please help me ,by letting me know how to do the following ……….

    i have class A with two variable one is string and another is int , know i create an object of this class and add it to a arraylist ….. till here it fine but i am not able to print it ……
    /* something like this
    class A
    String name=”hello”;
    int num=100;
    class TestArrayList
    P S V m(S[] a)
    A objA=new A();
    Arraylist al=new Arraylist();

    // how to print this arraylist ?? :-)

    Thanks in advance ……

  62. Rajesh

    A obj = new A();
    ArrayList list = new ArrayList();
    Iterator iterator = list.iterator();
    A a = (A)iterator.next();

  63. Shailaja


    could u please explain me which one is better to use in JSP pages, whether to use vector or arrayList in JSP Application ??

    Thanks in advance

  64. kashinath

    thanks sir very good example

  65. Anonymous

    Thanks a lot for giving such knowledge
    Sangeeta sahu

  66. kirubasankar selvaraj

    Thanks a lot for sharing precious information about vector ,array and array list.. its really been worth reading.

  67. haritha reddy

    its good……..

  68. Anonymous

    Very helpful..

  69. senthil kumar m.s.

    Thanks for giving an insight about the differences between Vector and ArrayList. As per the JavaDoc for ArrayList says below:

    The details of the growth policy are not
    specified beyond the fact that adding an element has constant amortized time cost.


  70. Prem

    Its Great!!!!

  71. Santosh

    Nice explanation

  72. Merlin

    Ya you clarified my doubt more clearly. Thank you.

  73. Anonymous

    your explanation is very good is sir and it is easily understandable to everybody but i want to know how can we know that a vector is synchronised. array list is not synchronised

  74. Pearly

    hey joe ..
    could u pls tell me how vector kills the performance..in brief…

  75. rahul

    nice explanatio sir,, i like it very informative

  76. Manas

    Hi Joe
    My question is
    “if ArrayList is there,Why we go for vector in collection”.U think due to synchronization.u can do it as ArrayList by SynchronizedList()as thread safe”.

    Which one is used in real time project in IT

  77. Arun

    i have a point that, vector can grow and can shrink according to the elements present in it. but Arraylist cant, we have to explicitly invoke the method trimtosize() to shrink it.vector is mostly used in web applications.

  78. Anonymous

    For concurrent accessing of thread which method in collection is possible ?

  79. Anonymous

    Please let me know the default size of the arraylist, vector and hash table

  80. Anonymous

    very nice

  81. Anonymous

    plz give me examples of arraylist,vector in realtime

  82. Anonymous

    Finally i got the answer thank u sir…….

    -Vilas R.Dandge

  83. Sandhya

    Hi Joe,

    Its very good blob, i got a lot of info in this. Would you explain one more difference?

    List list = new ArrayList();
    ArrayList list = new ArrayList();

    what is the difference between above two?

    • Rajnish

      Hi Sandhya,

      Both works in the same way however 1st approach is good. In this 1st approach we create a single reference variable of type List which refer to ArrayList object in the constant pool. Suppose we require to create LinkedList object in the same program so we can do like below:
      list = new LinkedList(). So here single reference variable list points to two objects.

      In the 2nd approach we create multiple reference variable pointing respective objects…..not a good approach though..


  84. SRUTI.M.K


  85. Anonymous


    RAM ON JUNE 25TH,2012 2PM

  86. Anonymous

    It would be great if you can put the comparison in a table.

  87. santhosh k s

    Hi Joe It’s good, easily can understand the things.
    put it in a Table

  88. anubhav

    Its easy to understand.

  89. Puneet

    Really Helpful.

    Thank You.

  90. Aravindh

    Its very nice definition for beginners like me now i clearly understand the difference thank you.

  91. praveen


  92. Omprakash

    Very nice explanation.. Explanation with an working example would be simply awesome and help in understanding the concepts behind them.

    Thanks for this.

  93. Excellent………
    Good to understand about vector and arraylist

  94. kishore

    Now in Java 1.5, instead of using Vector for Synchronized, we can use CopyOnWriteArrayList which is way better than using Vector in certain cases. Please explain the difference between them as its a hot question in interview these days.

  95. Tony

    Is there any practical example to prove the statement:-By default, Vector doubles the size of its array when its size is increased. But, ArrayList increases by half of its size when its size is increased.

  96. ilayarajakumaran

    Why vector and array list? why applet and swing? why hashmap and hastable? why ejb and spring? why string and string buffer? why errors and exceptions?

  97. moudhani

    good explanation….but we need example to understand as practically

  98. minakshi

    very nice sir

  99. minakshi

    very nice sir

  100. Thanks good explanation !!!

  101. Thanks for explanation in simple words and meaning full

  102. nanadha

    nice exp….thank u….

  103. nandha

    nice exp….thank u….

  104. saddam

    ur side is very good

  105. Bhushan

    Anybody Or Joe
    Please explain internal Array structure how collection are built on top of it

  106. Bhushan

    *Initial Capacity of ArrayList and Vector is 10

    *Only difference is that ArrayList doesn’t have the capacity() Method while Vector has.

    Internal implementation is similar for both the classes to set the initial size to 10.

    Challenging question to you ….
    what could be the reason with design prospective , capacity method has not put inside the ArrayList ?

  107. its good way of presenting about vector and arraylist
    plse give with programming

  108. Muthuraj

    Beautifully explained….very nice….Thanks Joe

  109. manoj

    Hi joe

    Tell me what particular situvation arraylist are not used vectors only used

  110. suman

    what is collection object

  111. Anonymous

    hey very nice concepts

  112. satya

    how to convert 2-dimensional array to hashmap

  113. s

    how to convert 2-dimensional array to hashmap

  114. Anonymous

    We can make arraylist as thread safe then why Vector is still available in Collection?
    Why Java does not deprecate this API?

  115. kishore

    how the ArrayList can be synchronized?

  116. kishore

    please send the answer to my mailid

  117. Naved

    Very good keep it up….

  118. Anonymous

    your explanation good……..thanks for spending your valuable time…….

  119. Ram

    Good explanation.But Can U provide if you have any programmatic experience about vector. Only this is the situation only vector is the solution like that way.


  120. Michael

    Just what I needed.
    Great. Keep it up.


  121. Anonymous

    Good Article indeed!

  122. Shirish Herwade


  123. mahesh

    give some clarification about abstract and encapsulation with some realtime examples

  124. Anonymous


    pratyasha on september 23rd, 2012

  125. vinod

    great work sir ,
    very easy to understand for beginners

  126. SardarWaqasAhmed

    Thats great explanation..Very easy to grasp the whole theory behind arraylist and vector.


  127. Ramesh


    Good Explanation.

    I have small doubt..

    we can covert the Array list as Synchronization easily..
    and why we go for vector…??

    if it is require to synchronization, we can use Array list Synchronization formula..
    so why vector is required….

    Pl.share me exact ans…


  128. Vikrant Dheer

    Hi joe ,
    pls can u share some diffferences between vectors and hash table !!!

  129. pallav rajput

    hi joe,

    i am bit confused with Load factor of Arraylist and Vector.

    can u please share some details regarding Load factor??

  130. Anonymous

    Hi joe,
    please tell me that how to reverse string in java without using function ?
    I am indian.
    indian am I.

    • Rajnish

      Here is the code:

      public class ReverseString
      PSVM(String as [])
      String Original=”I am Indian”;
      String Reverse=””;
      int length= Original.length();
      for(int i=length-1; i>=0;i–)

  131. Anonymous

    both will implement random access interface.

  132. Coming to load factor details:
    Vector: Increases by 2 times if capacityIncrement is not specified,

    hence newSize = size * 2;

    else newSize = size + capacityIncrement;

    Where as ArrayList directly increments the size by 1.5 times!

    Hence: newSize = ((size * 3)/2) +1;

    But My question is

    AbstractList implements List,
    Vector extends AbstractList and implements List
    Why Vector implements List again!!??

    Anyone knows !?!?

  133. @ram009.java@gmail.com

    Why Vector is used still !!????

    Answer is very simple ….

    Now a days nobody prefers to use vector anymore … but still in JDK for lower versions compatibility only!!!

  134. Anonymous

    thank you. very helful

  135. kiran

    thank you, very informative

  136. Joseph Kingston Leo . M

    very use full tips………..

  137. Nikhil

    I really like your theme!

  138. Mark

    Great work… more than enough in the difference….

  139. pradip garala

    good blog…

  140. Vinto

    Its a good work joe…
    If its possible please tell me the way by which i can make an arraylist synchronized….

  141. Naveen

    We can use Collections.synchronizedList(List arrayList) method to get the Synchronized list.

  142. Maga

    thnxs buddy for your answar………..

  143. u run javapapers mans what

    u run javapapers what does it mean fucker

  144. Gopa

    Good one. Keep it up.

  145. Muralidhar

    Hi Joe, you have covered most of the points wellknown..i need some new points apart from the below points:
    1.Vector is deprecated , ArrayList is not
    2.Vector is Synchronized , ArrayList is not
    3.Vector doubles its size , ArrayList is half when max size reaches
    4.Vector is preferable, because it is threadsafe(allows one by one)
    5. We can Synchronize Arraylist as Collections.synchronizedList(listObj);
    6.Interms of performance Vector is better

    apart from the above points Can you explain on both, how these will work in compiler level.

    Thank you
    Muralidhar N.

  146. Mahesh

    just started not covered even 0.01 percent of Collections

  147. jlj

    Best site for java people

  148. Ravi

    Hi Joe,
    Your explanation is awesome. No words to appreciate. Just a small request, please could you update more on collections.

  149. Nanda

    Simple with great explanation. simply superb

  150. very good explanation and thanks a lot…..

  151. rahul k k

    Excellent explanation….Thanks

  152. Bhavesh

    How collections are used?

    please reply on my email address
    its urgent.

    reply me on bhavesh71291@gmail.com


    • Rajnish


      As per as I know Collections is a class which contains many methods most common methods are sort…to sort the elements within collection and follow quick sort mechanism. Another one is syncronizedList, syncronizedSet and syncronizedMap methods to provide Syncronization version to the collection classes.

  153. Rajnish

    Hi Joe,

    I have gone through many books and online tutorials but unable to find the correct answer.. finally I have decided to post you as your explanations on java have been so friendly and nice… So here is my doubts:

    1) How to determine the capacity of an ArrayList? Which method is responsible for determining this in ArrayList? Does the LinkedList class capacity same as that of ArrayList or vector?
    2) Can you please define Fill ratio (Load capacity) in friendly way…not able to get good definition..):
    3) What is the Initial Capacity of HashSet, LinkedHashSet , TreeSet, HashMap, HashTable and TreeMap?

    I know my demand is too much…but I need to know and expecting a quick reply :)

  154. Shivi

    Hi Joe,

    Your explanation is great. Wondering if you can provide more info on JCF.

  155. Mayank

    ArrayList can perform operation using Iterator only whereas vector can perform operation using Iterator as well as Enumeration.

  156. yogesh sadula

    I have been reading all the java posts of yours..Its amazing feeling reading them. You post them with such an ease they become very easy to read and understand. i am looking for more posts and updates from you. If you have any other blogs for other technologies kindly email me. Thanks and great work….!!!

Your Comment