Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (4k points)

What happens (behind the curtains) when this is executed?

int x = 7;

x = x++;

That is when a variable is a post incremented and assigned to itself in one statement? I compiled and executed this. x is still 7 even after the entire statement. In my book, it says that x is incremented!

1 Answer

0 votes
by (46k points)

x acts become incremented. But you are allowing the old value of x rear toward itself.

x = x++;

  • x++ increases x and delivers its old value.
  • x = indicates the old value posterior to itself.

So in the finish, x gets allocated terminal to its primary value.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...