This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes little problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "little problem" Watch "little problem" New topic
Author

little problem

Rippon Jalali
Greenhorn

Joined: Aug 25, 2006
Posts: 23
when i am trying to run below program.the output comes='0'.
BUt shouldn't it come '1'.


public class t {
public static void main(String argv[]) {

int i =0;

i=i++;
System.out.println(i);
}


}
Stary Kapec
Ranch Hand

Joined: Dec 04, 2005
Posts: 81
int i = 0;
i=i++; // Here value of the expression i++ equals to 0, i is first incremented to 1, then assigned to the value of the expression, again to 0
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11855
    
  18

Here is a more detailed explanation.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: little problem
 
It's not a secret anymore!