A performance question only makes sense in a context where the functional behavior is identical (since, if the functionality is different, a correct behavior is superior to a minutely-faster one), so I'm assuming that you're referring to a situation where the value of the expression is not used? That is, where the only purpose of the expression is to increment i
? In such a situation, the answer is no: no performance difference, and in fact, no difference whatsoever. I just compiled this class:
public class Foo
{
public static void main(final String args[])
{
int i = Integer.parseInt(args[0]);
i++;
}
}
and computed the MD5 checksum of the resulting Foo.class
; and, similarly for a version with ++i
instead. They had the same checksum, indicating that the two versions were compiled into the exact same bytecode, and would therefore perform literally identically.
(Naturally, this could, in theory, depend on the compiler. A different compiler might decide to compile i++
differently from ++i
even in a context where they're equivalent. But I doubt that, and it's really not worth worrying about even if it the case.)