For this last bit it's just because the
for loop uses
j
for(int j = 1; j <= 100; j++) {
but the
if tests use
number as the index
if (allNum[number] == 0) {
...
}
if (allNum[number] == 1) {
...
}
else if (allNum[number] > 1) {
...
}
and the body of the
if blocks use
j for the array index, e.g.,
System.out.println(j + " shows " + allNum[j] + " times.");
Since you're interested in checking the values stored in the
allNum array from indices 1 to 100 (as in the
for loop), you obviously will need to use
allNum[j] in the
if tests as j is what you're using in the
for loop.