File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "little problem" Watch "little problem" New topic

little problem

Rippon Jalali

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;


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

Joined: Oct 02, 2003
Posts: 11653

Here is a more detailed explanation.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
It is sorta covered in the JavaRanch Style Guide.
subject: little problem