wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes increment operation-weird result Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "increment operation-weird result" Watch "increment operation-weird result" New topic
Author

increment operation-weird result

Jenny raj
Ranch Hand

Joined: May 19, 2005
Posts: 57
class test
{
public static void main(String args[])
{
int i=5;
for(int j=0;j<10;j++)
{
i=i++;
System.out.println(i);

}
}
}


output :
5
5
5
5
5
5
5
5
5
5



why the output is not 6,7,8....15

plz explain
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19073
    
  40

This exact issue is actually discussed in the JavaRanch FAQ.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: increment operation-weird result