Let's see a simple example where we are using ArrayList to store and traverse the elements. 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.ĥ) ArrayList uses the Iterator interface to traverse the elements.Ī Vector can use the Iterator interface or Enumeration interface to traverse the elements. It is introduced in JDK 1.2.Ĥ) ArrayList is fast because it is non-synchronized. Insertion and deletion operation in ArrayList is slower than an Array. Insertion and deletion operation is fast. In ArrayList we can store different datatype variables. In Arrays, we can store only one datatype either int, string, char etc. Vector increments 100% means doubles the array size if the total number of elements exceeds than its capacity.ģ) ArrayList is not a legacy class. ArrayList belongs to System.Collection namespace. ArrayListĢ) ArrayList increments 50% of current array size if the number of elements exceeds from its capacity. However, there are many differences between ArrayList and Vector classes that are given below. Next → ← prev Difference between ArrayList and VectorĪrrayList and Vector both implements List interface and maintains insertion order.
0 Comments
Leave a Reply. |