This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv 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

Win a copy of REST with Spring (video course) this week in the Spring 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: 11923

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:
subject: little problem
It's not a secret anymore!