ArrayList Vs Vector

What is the comparison of the cost of adding an object in Vector and in an ArrayList ( for which adding an element has constant amortized time cost).
[170 byte] By [anirudhchitnis] at [2007-9-26 1:17:35]
# 1

If you are adding an element to the end, the cost for both is O(1).

If you are adding an element to the beginning, the cost for both is O(n), where n is the number of elements currently in the list.

Vector is the old collection class. Don't use it unless you need to -- use ArrayList instead. If you need a thread-safe list, use a synchronization wrapper on the ArrayList.

schapel at 2007-6-29 0:47:18 > top of Java-index,Archived Forums,Java Programming...
# 2
ArrayList is almost same as Vector except that the other one is synchronized
pbalaram at 2007-6-29 0:47:18 > top of Java-index,Archived Forums,Java Programming...