Explain this | Sololearn: Learn to code for FREE!


Explain this

int k=10; k= k++; System.out.printl(k); Output in Java ??


4/29/2021 12:11:26 PM

abhishek bairwa

5 Answers

New Answer


Statement `k = k++;` is ineffective, because post increment operator returns the original value of <k>. Just do `k++` without reassigning the operator return value. System.out.println(...); // was System.out.printl(...); P.S. Please tag Java as the relevant language of the question ☝


abhishek bairwa https://www.sololearn.com/Discuss/2769875/?ref=app


Please explain easy for me


When written in a line, and not repeated, k++ Returns value of <k> unmodified, the modification (increment) takes place after the line is completely processed (after the semicolon - end of statement). The increment effect takes place on the next line. ++k Modifies (increments) value of <k> immediately, and returns the modified (incremented) value without waiting for the line to be completely processed. The increment effect takes place on the same line. * The output is the original value of <k>. You can verify this in Code Playground.


Sir what is the output