+ 5
What's the difference between x=x+2 and x++
for(int x=0; x<=10; x=x+2) { System.out.println(x); }
6 Answers
+ 10
x=x+2 //increments value everytime by 2
x++ //increments value by 1
+ 1
x=x+2 is incremented by 2and x is incremented by 1.
0
use the first if you are not sure what 2nd does
0
if you use x=x+1 then no difference