J ++ is implemented based on the "Intermediate cache variable mechanism" in java,
In layman's terms:
++ "Add first" (++ j)
++ Is "first assigned and then added" (j ++)
Public class Test1 {
Public static void main (String [] args ){
Int I = 10;
Int a = 0;
Int B = 0;
Int c = 0;
Int d = 0;
// A = I ++; // 21
/*
* Temp1 = I; 10
* I = I + 1; 11
* Temp2 = I; 11
* I = I + 1; 12
* A = temp1 + temp2 = 21;
*/
// B = ++ I; // 23
/*
* I = I + 1; 11
* Temp1 = I; 11
* I = I + 1; 12
* Temp2 = I; 12
* B = temp1 + temp2 = 23;
*/
// C = ++ I + I ++; // 22
/*
* I = I + 1; 11
* Temp1 = I; 11
* Temp2 = I 11
* I = I + 1; 12
* C = temp1 + temp2 = 22
*/
D = I ++ I; // 22
/*
* Temp1 = I; 10
* I = I + 1; 11
* I = I + 1; 12
* Temp2 = I; 12
* D = temp1 + temp2 = 22;
*/
System. out. println ();
System. out. println (B );
System. out. println (c );
System. out. println (d );
}
}