wood burning stoves 2.0*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 11153
    
  16

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
 
Similar Threads
Strange behaviour of bit shifting
A funny program I just write,Check!
Game of Life Help
ebcdic to ascii
Sudoku Solver