I am initializing an array like this:
public class Array {
int data[] = new int[10];
/** Creates a new instance of Array */
public Array() {
When you create an array of size 10 it allocated 10 slots but from 0 to 9. This for loop might help you see that a little better.
public class Array {
int[] data = new int[10];
/** Creates a new instance of an int Array */
public Array() {
for(int i = 0; i < data.length; i++) {
data[i] = i*10;
}
}
}