This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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: 18500
    
  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
 
Similar Threads
Q#5 majji. Can any one explain this please??
pl explain
Help! Jsp Declaration Question
Assertion Question
From JQ+