anyone please provide deep information
What is the difference between Array list and vector in Java?
sanjay mca (19 Points)
31 December 2020sanjay mca (19 Points)
31 December 2020anyone please provide deep information
Meghna Singh
(8 Points)
Replied 22 January 2021
ArrayList and Vector both implements List interface and maintains insertion order.
However, there are many differences between ArrayList and Vector classes that are given below.
ArrayList | Vector |
---|---|
1) ArrayList is not synchronized. | Vector is synchronized. |
2) ArrayList increments 50% of current array size if the number of elements exceeds from its capacity. | Vector increments 100% means doubles the array size if the total number of elements exceeds than its capacity. |
3) ArrayList is not a legacy class. It is introduced in JDK 1.2. | Vector is a legacy class. |
4) ArrayList is fast because it is non-synchronized. | Vector is slow because it is synchronized, i.e., in a multithreading environment, it holds the other threads in runnable or non-runnable state until current thread releases the lock of the object. |
5) ArrayList uses the Iterator interface to traverse the elements. | A Vector can use the Iterator interface or Enumeration interface to traverse the elements. |
Meghna Singh
(8 Points)
Replied 22 January 2021
If it is not against the community guidelines I would suggest some links regarding this,
https://www.javatpoint.com/difference-between-arraylist-and-vector
https://www.geeksforgeeks.org/vector-vs-arraylist-java/
I hope this will work for you.
Thanks & Regards
Seema
25 Hours GST Scrutiny of Return and Notice Handling(With Recording)
Survey, Search and Seizure under Income Tax Act 1961