Hello Daniweb,
I can't wrap my head around this minor issue. Maybe it's a known bug and I just can't find the right keywords to google it or maybe it's supposed to be like this. Let me know what you guys think.
public class TestPostfix {
public static void main(String args[]) {
int x = 3;
x = 6 + x++ * 3 / 2 - 3;
System.out.println(x);
}
}
Why does that print 7? "x" evaluates to 7 and rightly so, but the increment operator doesn't seem to kick in to set it to 8 before it's printed.
// This prints 9
x = 6 + ++x * 3 / 2 - 3;
The prefix prints 9 like it should, but can someone explain why the post fix isn't evaluating at the end of the statement?