+ 1
Can anyone please explain to me what is a postfix?
I want a more briefly explained definition about postfix
2 Answers
+ 15
i = 5; System.out.println(++i); //6
This prints out "6" because it takes i adds one to it and returns the value. 5+1=6; This is prefixing, adding to the number before using it in the operation.
i = 6; System.out.println(i++); //6 (i = 7, prints 6)
This prints out "6" because it takes i, stores a copy, adds 1 and returns the copy. So you get the value that i was, but also increment it at the same time. Therefore you print out the old value but it gets incremented. The beautfy of a postfix increment.
Then when you print out i, it shows the real value of i because it had been incremented. 7
source: stackoverflow.com
0
Thanks