Java - For Loop

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.
Sep 29, 2004
18,656
67
91
Everything should default to 0. Array indices starting at 0 is not really a feature of a programming language. Its basically forced by the computer architecture. (I mean... you could start at 1, but then you'd have to subtract 1 every time you index into an array or offset a pointer).

Not really talking indices. Just default values. The C/C++ language specs do not require defaults. A compiler can use whatever happens to be in memory as a default if it wants. Java is different. It dictates defaults per language spec. That's all I am saying.

Array indices in C/C++ are just pointers. They pretty much have to be index zero since that is the location they represent. I'm not sure how Java handles arrays per language spec.
 

Leros

Lifer
Jul 11, 2004
21,867
7
81
Not really talking indices. Just default values. The C/C++ language specs do not require defaults. A compiler can use whatever happens to be in memory as a default if it wants. Java is different. It dictates defaults per language spec. That's all I am saying.

Array indices in C/C++ are just pointers. They pretty much have to be index zero since that is the location they represent. I'm not sure how Java handles arrays per language spec.

My bad. Thought we were talking about array indices still.