Why it always, must, be minus -1 in Array

Hi, there.
I wonder why despite the fact that we start from 0. Why we have to do minus 1. to arrays

Because the count includes the zero element and when you want to get to the last element using the count you have to minus 1

Keep it simple. Think of a one element array, We know that it’s length/count is one correct? But we also know that to address the first element of the array we have to You zero. So length/count 1 - 1 is element 0

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms