Hello. Can someone please tell me why the following code yields an output of 0 instead of 1? int i = 0; i = i++; System.out.println(i); Since the output is 0, does this mean that the increment in this particular case is useless?
I would cahracterize this one as a bug in the JVM. I understand why this occurs, but this is not the expected result. You should not have to think about how the compiler does its work to determine what the answer will be. The operator is posfix and nobody would expect the result to be 0 when it prints. Anyone agree or disagree?