Java - Turning the for-loop counter back based on a conditional
问题 The following is part of the code for my college assignment. else if (!codeList.contains(userCode)) { i--; // i is the counter for the for-loop } else if (userQuantity[i]==0) { i--; } The first part makes sure that if the user enters the wrong code, the counter i does not increment 1, or rather, it subtracts 1 from the recently incremented counter. This part works fine. The second part however is what I seem to be having problems with. userQuantity[] is an int array and it has to be an array.