Sure you could do this to count the iteration
But put the ‘int iterationCheck=0’ variable declaration before the do/while scope.
You could go for a ‘for’ loop too ( which would be better )
However it all depends on the condition of your loop.
Because we can’t infer the ‘out’ condition of your loop so we can’t provide a accurate answer.
2
solved Do while loop check for last iteration [closed]