+ 14
• Increment and Decrement Operators Like C and C++, Java provides increment and decrement operators. Specifically, it provides the plus-one increment (++) and decrement (−−) operators.  • If such an operator is used in front of a variable reference, then 1 is added to (or subtracted from) the variable and its value is read into the expression.  • If it is used after a variable reference, then the value is first read and then the variable is incremented or decremented by 1. So, for example, the code fragment     int i = 8;     int j = i++;     int k = ++i;     int m = i−−;     int n = 9 + i++; assigns 8 to j, 10 to k, 10 to m, 18 to n, and leaves i with value 10. • https://code.sololearn.com/chPAcDs7YZgV/?ref=app
7th May 2019, 2:59 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 1
If you use the prefix incrementation, it is first incremented then returned. The postfix returns the value first then increments. Both are correct, depends on what you want to achieve.
7th May 2019, 1:55 PM
{ 𝄋 ℒ 𝄋 }
{ 𝄋 ℒ 𝄋 } - avatar