File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

little problem

 
Rippon Jalali
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 81
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 12015
24
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is a more detailed explanation.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic