- 1
Explain this
int k=10; k= k++; System.out.printl(k); Output in Java ??
5 Respuestas
+ 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 ☝
+ 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