Differentiate between array and vector.
Array
|
Vector
|
1) An array is a structure that holds multiple values of the same type.
|
1)The Vector is similar to array holds multiple objects and like an array; it contains components that can be accessed using an integer index.
|
2) An array is a homogeneous data type where it can hold only objects of one data type.
|
2) Vectors are heterogeneous. You can have objects of different data types inside a Vector.
|
3) After creation, an array is a fixed-length structure.
|
3) The size of a Vector can grow or shrink as needed to accommodate adding and removing items after the Vector has been created.
|
4) Array can store primitive type data element.
|
4) Vector are store nonprimitive type data element.
|
5)Declaration of an array : int arr[] = new int [10];
|
5) Declaration of Vector: Vector list = new Vector(3);
|
6) Array is the static memory allocation.
|
6) Vector is the dynamic memory allocation.
|