Vector |
ArrayList |
Synchronized |
- Yes
- The contents are thread safe
- Here Vector is slower
|
- NO
- The contents are not thread safe.
- Here ArrayList is Faster
|
Stretchable (capacity) |
- Both arranges the data internally and expands if run our
of the room.
- ArrayList ist set to 10 by default, reaching the last
element , ArrayList would tender new array, then the old one
would be subject to garbage collection.
|
- increases by double or two fold
- For an unknown case, Vector is better logically.
|
- increases by 50 per cent
|
|
|
Adding in the middle |
- Both maintain data in ordered fashion, positional
indexes are added with the objects.
- Both will take a toll, as the removal will increase or
decrease the indices from the reference point of addition or
removal respectively.
- Both may affect the speed when accessing elements in
the middle.
- Consider LinkedList for adding and removing elements
very frequently.
|
Performance |
- Vector slow safe thread
|
- in ArrayList two or more threads can access the code at
the same time
|
Enumeration |
- Vector Like Hastable supports Enuumeration and Iterator
|
- ArrayList can only use iterator
|
|
|
|
|