File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes i didnot get the actual output of this simple increment operator..  ++ Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "i didnot get the actual output of this simple increment operator..  ++" Watch "i didnot get the actual output of this simple increment operator..  ++" New topic
Author

i didnot get the actual output of this simple increment operator.. ++

Mr. Sunil Parmar
Greenhorn

Joined: Oct 13, 2008
Posts: 3
I have the following code:

public static void main(String args[]){
int i = 0;
i = i++ ;
System.out.println(i);
}


Output : is 0

but dont know ?

If any body know the reason behind that than please help...


Thanks & Regards..


Thanks & Regards
Sunil Parmar
Smitesh Shinde
Ranch Hand

Joined: Feb 16, 2008
Posts: 45

What do you expect it to print? Please do some research on pre-increment and post-increment operators.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
That question comes up frequently, and seems to confuse lots of people. Start by looking at this old thread, and this FAQ.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: i didnot get the actual output of this simple increment operator.. ++