Decrement and assignment operator in java [duplicate]
问题 This question already has answers here : Is there a difference between x++ and ++x in java? (16 answers) Closed 3 years ago . Can somebody explain why output of the code below is 1. int i = 1; i=i--; System.out.println(i); // 1 回答1: i-- does the following steps: return the value of i decrement i by 1 so the statement i = i-- does the following: i is returned (the statement now equals i = 1 ) i is decremented (i is now 0) the statement (the assignment) is now done ( i = 1 ) In the end i is 1