Pergunta

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();
 }
Foi útil?

Solução

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 em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top