An Array are continues memory allocation
which contains homogenous set of data.
An array is container object that holds a fixed
number of values of same/single type.
Array can be created as:
int arr1[] = {10,20,30,40,50};
int arr2[] = new int[] {10,20,30,40,50};
int arr3[] = new int[5];
we can find size of array by using
build-in property i.e. length
e.g. arr3.length;
which returns int value
NOTE : Array always begins with index zero
We can't access array element beyond the range
We can't resize the array but can use same
refernce variable to new refernce array
e.g. int ar[] = new int[5];
ar[] = new int[10];
ArrayCopy
To copy array elements from one element
to another array, we use a static method
arraycopy from System class
public static void arraycopy(ar1,s_index,ar2,s_index,ar1.length);
0 comments:
Post a Comment