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();
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Be careful with
count++. It evaluates to the current value of thecount, then increments afterward. So ifcountis 3, andmaxis 3,count++ > maxwill return false, and then incrementcount. It looks like you want++count, which increments, and then evaluates.