There is definitely no difference between ++i and i++ if they are used as statements on their own. Only the presence of an additional assignmentforces a difference in the compiled bytecode.In the context of an assignment, it is possible that comparing theuse of the pre-increment or post-increment operators could result indifferent runtimes. But that is unlikely where the functional result ofusing either is the same.
public class Increment{ public Increment() { int i = 0, j = 0; System.out.println( "1- j = " + j ); j = i++; // prints 0 but infact the value of j is 1. System.out.println( "2- j = " + j ); // j will be 2 now. j = i + 1; System.out.println( "3- j = " + j ); } public static void main( String[] args ) { new Increment(); }}
What's the "performance" difference between i++ and ++i? 2 senarios:1. i++; vs ++i;2. int j = i++; vs int j = ++i;