Why the output of the foll.prog is = 0 ?????????//
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mandar_Pohnerkar
Posted On:   Friday, July 19, 2002 03:52 AM

hello

			

Why the output of the foll.prog is = 0 ?????????//
Why the output of the foll.prog is = 0 ?????????//

public class Incre
{
public static void main(String[] args)
{
int i=0;
i=i++;
System.out.println(i);
}
}

Mandar

Re: Why the output of the foll.prog is = 0 ?????????//

Posted By:   Thomas_Hackel  
Posted On:   Friday, July 19, 2002 04:48 AM

its like in c++...

use i=++i; instead of i=i++;

i++= i is incremented after the expression is evaluated.

(usable for FOR loops etc)

++i= i is incremented before the expression is evaluated.
About | Sitemap | Contact