Using of Modulo operator to prevent ArrayIndexOutOfBound error

#1

Hello Everyone,

I am a newbie in programming world and I expect your support on this forum.
I am confused at code line in the GeoQuiz App:
mCurrentIndex = (mCurrentIndex + 1)%mQuestionBank.length;

Here, I understand that without Modulo sign it will generate ArrayIndexOutOfBound exception error, but the thing that is confusing me here that when i try to calculate the remainder of every iteration on paper, the result is remainder =0, then how this line of code is running perfectly?

#3

The remainder cannot be zero until the numerator matches the denominator i.e. 5 in this case. If numerator is less than the denominator the result of the modulo is always numerator