Fixed Why does this go into an infinite loop? #dev #it #asnwer
Fixed Why does this go into an infinite loop? #dev #it #asnwer
Why does this go into an infinite loop?
I’m a teacher, and yesterday a student wrote the following code:
public class Tests { public static void main(String[] args) throws Exception { int x = 0; while(x<3) { x = x++; System.out.println(x); } } }
We know he should have writen just x++ or x=x+1, but on x = x++;it should first attribute x to itself, and later increment x. Why does x continue with…
View On WordPress
















