I declared an array as shown below:
int[] arr = new int[10];
Then I assigned following values to the array:
arr[0] = 1;
arr
`
int array[]=new int[3]; array.length;
so here we have created an array with a memory space of 3... this is how it looks actually
0th 1st 2nd ...........> Index 2 4 5 ...........> Number
So as u see the size of this array is 3 but the index of array is only up to 2 since any array starts with 0th index.
second statement' output shall be 3 since the length of the array is 3... Please don't get confused between the index value and the length of the array....
cheers!