I came across the following issue:
private void doStuff(int i) {
if(i>10) {
return;
}
doStuff(i++);
}
public void publicMethod() {
doStuff(i);
}
I would expect this to run doStuff
10 times and then return.
However i++
does not get executed before the doStuff
is called again with 0
.
Result is an infinite loop. I know how to fix it but I am wondering if this behaviour is correct or a bug.
doStuff(++i)
instead. – Review