Whys does this print 0, not 1?
public static void main (
String[] args) {
int i = 0;
i = i++; // (1)
System.out.println(i);
}
Doesn't i get incremented by 1 after assinging 0 to i on line (1)?
Here is my thinking process.
i is 0 at initialization. i gets i on line(1), which is 0, then i gets incremented by 1 with i++. Then when you print i it seems like it should print 1, not 0.
It would be perfectly understandable if i++ was getting assigned to some other variable and that variable is being printed.
It behaves like there are two different i's.
[ January 08, 2003: Message edited by: Harry Kong ]