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.
Chat with our AI personalities
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
what are the differents between preindexing and post indexing?
It's a difference in mentality; some believe 0 is the begin, and is thus the only logical choice, and some think the opposite.
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.
...letter.