This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

post increment operator

 
sanjay kumaresan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Respeted Sir/Madam,
We have a doubt in the following code:-
class Sample
{
public static void main(String args[])
{
int i=10;
i=i++;
System.out.println("The value of i is: " + i);
}
}
When I run the program,it is giving the output as 10.
Why so?If I store the result in another variable,it is taking as 11.What is the difference between both the cases?
Thanking you,
M.Sanjay.

 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ask it in Beginner. Or just look for this conversation in other threads. It has been discussed many times.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic