my dog learned polymorphism*
The moose likes Ranch Office and the fly likes post increment operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » This Site » Ranch Office
Bookmark "post increment operator" Watch "post increment operator" New topic
Author

post increment operator

sanjay kumaresan
Greenhorn

Joined: Jun 29, 2001
Posts: 8
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

Joined: Sep 29, 2000
Posts: 8521
Ask it in Beginner. Or just look for this conversation in other threads. It has been discussed many times.


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: post increment operator
 
Similar Threads
Serial killer or computer programmer?
25 horses to win, place, show
Array Data Print Out
The best puzzle(IIM Indore)
Array