Why is the currentIndex increased then module by questionBank.length?
mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length;
I understand that we are increasing the index to get the next question but why the module?
Why is the currentIndex increased then module by questionBank.length?
mCurrentIndex = (mCurrentIndex + 1) % mQuestionBank.length;
I understand that we are increasing the index to get the next question but why the module?
The modulus “resets” the mCurrentIndex to 0 when the end of the array is reached.
Ex. If the array length is 8 and the current value of mCurrentIndex is 7 then, by the assignment, mCurrentIndex = 7. Next iteration results in mCurrentIndex = 0.