+ 1
Guys i can't understand the difference between prefix and postfix
4 Answers
+ 8
It is pretty simple.
Pre means before
Post means after
In your example
x = 14;
system.out.print (x++);
14 is printed because x is incremented 'after' (postfix) the print statement is executed.
+ 2
if you are talking about the Increment and Decrement (++ or --)
[https://www.sololearn.com/Discuss/774439/difference-between-prefix-a-and-postfix-a]
+ 2
it is very easy....
prefix (++x) adds 1 to the valuee of x and then assigns to the X....
postfix (x++) uses value of x and then add 1 to the value of X....
here,,
x=3;
y=x;
x++ will result in x=4... it will just change the value of itself accoriing to the condition above while in case of prefix..
x will be 4 and y will also be 4.... because here x has value for and according o the condition it will use its value and assing to y..
very simple...
+ 1
But why in the example in the app x=14 and system.out.print(x++) output 14 and not 15 ? Can anyone explain to me , please ?