0

Is there a logical reason that arrays in most languages are zero-indexed?

18th Oct 2016, 1:57 AM
tomgreenfanus
2 Respostas
0
This is just a gues, but all bases start counting with 0 and binary is a common base in computers which is made of 1s and 0s so it only makes sense to start with the first number. If this is wrong remember it's just a semi-educated guess
25th Oct 2016, 5:16 PM
Greg M
Greg M - avatar
0
There is. Java inherits arrays syntax from C language. And in C array variable stores just an address of the first element. And position of every element is calculated as sum of beginning address and element index. While you already have starting address you don't need to add anything to get it. So it's logical that first index is zero.
29th Oct 2016, 8:06 AM
Леонид Порожнета
Леонид Порожнета - avatar