answersLogoWhite

0


Best Answer

Primarily to be compatible with C and C++, which was one of the goals of Java when it was being designed (minimize the learning curve for those familiar with C and C++ to increase adoption). Speaking from a lower-level perspective, arrays are accessed by a pointer and an index. If you call the pointer PTR, and the index IDX, you can access an element in the array by using PTR+IDX. In order to avoid wasting memory, IDX may be zero, since PTR is already allocating that memory to the existence of the array. In languages where IDX starts at 1, PTR[0] stores the number of elements in the array, and can't be directly accessed. Java stores the length of the array elsewhere (in the variable "length"), and so it can start its element allocation at zero.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Why does indexing start with 0 in Java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

When was Java Web Start created?

Java Web Start was created in 2001.


Indexing method in milling machine?

Direct Indexing, Simple Indexing, and Angular Indexing


What is the difference between pre-indexing and post-indexing?

what is pre-indexing


What is a java web start used for?

The Java Web Start software allows one to download and run Java applications. Java Web Start is very easy to use and ensures that one is always running the latest version of this application.


Why you start java program by class?

without class non of the folder can run so the java program should start in class we can use the class without object in java


Pre indexing post indexing difference between?

what are the differents between preindexing and post indexing?


How much do Java pay Jagex?

$0


What engineeer start with an J?

java engineer


Why c and java arrays are start with zero and pascal arrays are start with one?

It's a difference in mentality; some believe 0 is the begin, and is thus the only logical choice, and some think the opposite.


Where java program started?

If it is already compiled, you can start your Java program from the command line. Just type java myclass replacing "myclass" with the program you want to start - a program with the ".class" extension, for example, myclass.class.


What has the author Pat F Booth written?

Pat F. Booth has written: 'Choice and form of entries' -- subject(s): Corporate headings (Cataloging), Indexing, Names, Personal (Cataloging), Programmed instruction, Subject headings 'Training in indexing' -- subject(s): Indexing 'Indexing the Manual of Good Practice' 'Documents, authors, users, indexers' -- subject(s): Cataloging, Indexing, Programmed instruction 'Indexing' -- subject(s): Indexing


What are some engineering that start with j?

java engineer