Should element numbering start from 0 or 1 in Java?

Viewed 6064

I'm trying to learn the concept of index and element in Java. I have seen two versions of representations for elements and am not sure which one is correct.

For an array with 4 elements, the first version assigns Element(0) to the first element, Element(1) to the second element and so on. This version is shown as the graph below.

enter image description here

The second version, Element(1) is assigned to the first element, Element(2) is assigned to the second element and so on.

I'm very confused as to which version of representing elements is correct and which is wrong, this is causing me a lot of confusion.

6 Answers
Related