post increment question

I was looking at this puzzle question:

public class Assignment {

public static void main(String[] a) throws Exception {

int tricky = 0;

for (int i = 0; i < 3; i++)

tricky += tricky++;

System.out.println(tricky);

}

}

tricky is 0. How come the post increment in this case does nothing?

[352 byte] By [flybuzza] at [2007-11-27 5:11:34]
# 1
This has been asked a gazillion times before. Please use the search function.
floundera at 2007-7-12 10:31:59 > top of Java-index,Java Essentials,New To Java...
# 2

> I was looking at this puzzle question:

>

> public class Assignment {

> public static void main(String[] a) throws Exception

> {

>int tricky = 0;

> for (int i = 0; i < 3; i++)

>tricky += tricky++;

> System.out.println(tricky);

>}

>

> tricky is 0. How come the post increment in this case

> does nothing?

http://forum.java.sun.com/thread.jspa?forumID=54&threadID=753569

lem@phila at 2007-7-12 10:31:59 > top of Java-index,Java Essentials,New To Java...