Circular Tally Counter Not Rolling Over [closed]
-
30-06-2021 - |
Pregunta
I was practicing my java and was trying to make a simple counter with rollover at max, but for some reason it isn't rolling over. Any advice?
if(count++ < max){
click();
}
Solución
Be careful with count++
. It evaluates to the current value of the count
, then increments afterward. So if count
is 3, and max
is 3, count++ > max
will return false, and then increment count
. It looks like you want ++count
, which increments, and then evaluates.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow