+ 4
Why we use x++ in java?
public class Program { public static void main(String[] args) { int x = 10; int y = x++; System.out.println(y); } } //output is 10
3 Answers
+ 1
x++ means your incrementing value on x by 1 so x will be 11.
In your example x=10 and y has assigned value of x which is 10 but the increment operator is on right which is called post increment which will increment value on next output of y. Try to output y two time to get 11 as output.