+ 2
When would you use postfix vs the prefix ? Please show an example?
2 Respuestas
+ 5
When you want something incremented/decremented before you use the variable, you must use prefixed operator, otherwise the variable will be used first and icremented after: e.g.
var i = 0;
var j = 0;
document.write(++i);
document.write(j++);
The values printed will be respectively 1 and 0.
The use of each other will vary accordingly with your necessity.
0
in simple way Suppose u have any variable like Int a=10;
and u want to use it start with 11 then u need preIncrement... it increments the value first then exicute..
int a =10;
system.out.println(++a);
output = 11