Explain this | Sololearn: Learn to code for FREE!

-1

Explain this

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

h

4/29/2021 12:11:26 PM

abhishek bairwa

5 Answers

New Answer

+2

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 ☝

+2

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

+1

Please explain easy for me

+1

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.

0

Sir what is the output