Array Length in Java

前端 未结 16 1437
忘了有多久
忘了有多久 2020-11-30 21:27

I declared an array as shown below:

int[] arr = new int[10];

Then I assigned following values to the array:

arr[0] = 1;
arr         


        
16条回答
  •  情深已故
    2020-11-30 22:16

    if you mean by "logical size", the index of array, then simply int arrayLength = arr.length-1; since the the array index starts with "0", so the logical or "array index" will always be less than the actual size by "one".

提交回复
热议问题