I was looking at some certified
Java programmer sites, when I came across the
following code:
public static void main(
String[] arguments)
{
int i = 0;
int j = 5;
i = i++;
System.out.println("value of j is = "+j);
System.out.println("value of i is = "+i);
}
When run the result is:
value of j is = 5
value of i is = 0
My question is I assume that the i would be set to 0 by the
assignment of i = i. But then before running the next statement
i would be incremented to a value of 1. Based upon the running of the
code this is not what happens.
Can someone please explain why i is not incremented after being assigned
the value of 0.
THANKS