PRE-INCREMENT (++X) VS POST-INCREMENT (X++) -------------------------------------------- In class we discussed the difference between x++ and ++x; Note that they are identical if they are the only thing in a line. Also note that they do not follow BEDMAS. ++x happens BEFORE anything else on the line and x++ happens AFTER anything else on the line. Type the following code into a Java file, compile, and run it. Explain the results. Notice that same thing will happen with x-- and --x . public class PrePostTest { public static void main (String args[]) { int x=5, y=5; System.out.printf("x,y:\t\tx=%d, y=%d\n",x,y); y=x++; System.out.printf("y=x++\t\tx=%d, y=%d\n\n",x,y); x=y=5; System.out.printf("x,y:\t\tx=%d, y=%d\n",x,y); y=++x; System.out.printf("y=++x\t\tx=%d, y=%d\n\n",x,y); System.out.printf("x,y:\t\tx=%d, y=%d\n",x,y); ++x; y++; System.out.printf("++x, y++\tx=%d, y=%d\n",x,y); } }