Worked example
You can visit every value with an enhanced for loop (for-each), which hands you each value in turn — no index needed:
int[] scores = {85, 90, 95, 100};
int sum = 0;
for (int s : scores) { // s takes each score in turn
sum = sum + s;
}
double avg = (double) sum / scores.length; // 370 / 4 = 92.5
System.out.println(avg);
The sum is 370; dividing as doubles gives 92.5. Without the cast, 370 / 4 is integer division and would give 92. (An indexed for loop works too, but for-each is cleaner when you don't need the index.)