This week's book giveaway is in the Agile forum.
We're giving away four copies of The Software Craftsman and have Sandro Mancuso on-line!
See this thread for details.
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


Win a copy of The Software Craftsman this week in the Agile forum!
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: 19528
    
  42

This exact issue is actually discussed in the JavaRanch FAQ.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
wood burning stoves
 
subject: increment operation-weird result