0
Question about post-increment
Hey! I got the following answer in the quiz: int x = 1; x += x++; System.out.println(x); x is 2 in the end. My question: 1 += 1++; Shouldn't the post-increment be added now? Inbetween the calculation and out.print? So the result should be 3?
2 Respostas
0
I would say that this expression is undefinded.
An example with two variables:
int x = 1;
int y = 1;
y += x++
first add value of x to y -> y is now 2
than increment x -> x is now 2