I noticed that if I declare an array as:
int[] myarr = new int[10];
I can directly use myarr[1] ++;
so that myarr[1] = 1
. Does it mean that in Java, we do not need to initialize the array and set each value as 0 by the following method?
for (int i = 0; i < myarr.length; i++) {
myarr[i] = 0;
}
I saw from some comments that the array may contain garbage values. If the array is an integer array, will it contain any garbage other than 0?