The second snippet is fairly straightforward.
When you say y = x++ what you're doing is first assigning y to x and then incrementing x, so y has a zero value and x has one. But it's really strange that the first snippet is acting the way it is.
I tested it in C and it performs ok (answer is 1) but I wonder why it's not working in
Java.
Any suggestions?
Sashi