dam1ne :
I have a do while loop
int maxItter = 20;
int index = maxItter;
do {
index --;
int itterNum = maxItter-index;
//stuff
} while (index > 0);
index = index + 1;
Where maxItter
equals the maximum number of iterations and itterNum
being the current iteration the do while loop is on.
After 20 iterations, I want 'itterNum' to restart at 0
How do I do this?
i.bondarenko :
I hope I get your question correct. In this case you will get infinite loop:
public static void main(String[] args) {
int maxItter = 20;
int index = maxItter;
do {
index --;
int itterNum = maxItter-index;
//stuff
if (itterNum == 20) {
index = 20;
}
System.out.println(itterNum + " " + index);
} while (index > 0);
index = index + 1;
}
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=310734&siteId=1