Positioning and prediction are very similar operators. Java bytecode gives a better understanding. Each of them consists of two operations. Download the variable and increase it. The only difference is in the order of these operations. If the statement in your case is composed as follows:
4: iload_1 //load x 5: iinc 1, -1 //decrement x 8: iinc 2, -1 //decrement y 11: iload_2 //load y 12: if_icmple 23 //check two values on the stack, if true go to 23rd instruction
When the JVM matches an if statement, it has 3 and 2 on the stack. Lines 4 and 5 are compiled from x-- . Lines 8 and 11 of --y . x loads before increment and y after.
By the way, it is strange that javac does not optimize this static expression.
Mikhail
source share