Professional Documents
Culture Documents
2 5 2 P 603c609dc3377 File
2 5 2 P 603c609dc3377 File
<<MSBTE LEAD>>
Unit 02 :
Derived Syntactical
Constructs in Java
Written by
An array is a structure that holds multiple values of the The Vector is similar to array holds multiple objects and
same type. like an array; it contains components that can be accessed
using an integer index.
An array is a homogeneous data type where it can hold Vectors are heterogeneous. You can have objects of
only objects of one data type. different data types inside a Vector.
After creation, an array is a fixed-length structure. The size of a Vector can grow or shrink as needed to
accommodate adding and removing items after the Vector
has been created.
Array can store primitive type data element. Vector are store non-primitive type data element.
Array is unsynchronized i.e. automatically increase the size Vector is synchronized i.e. when the size will be exceeding
when the initialized size will be exceed. at the time; vector size will increase double of initial size.
Declaration of an array : Declaration of Vector:
int arr[] = new int [10]; Vector list = new Vector(3);
Array is the static memory allocation. Vector is the dynamic memory allocation.
Array allocates the memory for the fixed size ,in array Vector allocates the memory dynamically means according
there is wastage of memory. to the requirement no wastage of memory.
No methods are provided for adding and removing Vector provides methods for adding and removing
elements. elements.
In array wrapper classes are not used. Wrapper classes are used in vector.
Page 11 Array is not a class. Maharashtra State Board of Technical Education Vector is a class.
Quick Revision