Skip to content

Latest commit

 

History

History
2 lines (2 loc) · 557 Bytes

File metadata and controls

2 lines (2 loc) · 557 Bytes

What is the difference between ArrayList and vector?

Ans. ArrayList is not thread-safe whereas Vector is thread-safe. - In the Vector class each method is surrounded by a synchronized block and thus making Vector class thread-safe. - Both the ArrayList and Vector hold onto their contents using an Array. - When an element is inserted into an ArrayList or a Vector, the object will need to expand its internal array if it runs out of room. - A Vector defaults to doubling the size of its array, while the ArrayList increases its array size by 50 percent.