The following table shows the main differences between 'ArrayList' and 'Vector' in Java Technology.
ArrayList | Vector | |
1 | ArrayList uses java.util.ArrayLIst class | Vector uses java.util.Vector class |
2 | ArrayList increases by half of its size when its size is increased. | Vector doubles the size of its array when its size is increased. |
3 | All methods of ArrayList are not synchronized and hence it is not thread – safe. | All the methods of Vector are synchronized and hence it is thread – safe. |
4 | Performance is High because of methods of ArrayList is not synchronized. | Performance is Low because of methods of Vector is synchronized. |
5 | The default size for ArrayList is 10. | The default size for Vector is 10. |
6 | Not suitable for use in multi – threading environment. | Suitable for use in multi – threading environment. |
7 | ArrayList returns iterator and ListIterator of items. | Vector returns Enumeration of items. |
8 | Use ArrayList as much as possible. | Avoid use of Vector until you have no choice to use. |
Related Articles:
Difference between static class loading and dynamic class loading in java
Difference between Array and ArrayList in Java
Difference between Abstract Class and Interface in Java
Difference between String and StringBuffer/StringBuilder in Java
Difference between HashMap and HashTable in Java
Difference between Csharp and Java
Difference between Method Overloading and Method Overriding in Java
Difference between ‘is-a’ relationship and ‘has-a’ relationship in Java
Difference between C++ and Java