I'm trying to understand what a watch is or how it works with the program. In any case, this is a block of code that I am trying to understand. I know this is a sentinel control cycle, but I donβt know what he is doing.
private static final int SENTINEL = -999
From what I have Google, is that having a negative integer, it indicates the end of the sequence. But how is this done? Oh, and how do I initialize the sentinel? Is it already initialized?
public static int gameScore(int[] teamBoxScore) {
int output = 0;
for (int v : teamBoxScore){
if (v !=SENTIENL) {
output += v;
}
}
return output;
}
Please thanks! I am learning how to code Java
source
share