Results 1 to 5 of 5
Thread: hi
- 11-13-2007, 10:51 AM #1
Member
- Join Date
- Nov 2007
- Posts
- 2
- Rep Power
- 0
- 11-13-2007, 11:42 AM #2
Hi Arun, welcome..
- 11-13-2007, 11:51 AM #3
Member
- Join Date
- Nov 2007
- Posts
- 2
- Rep Power
- 0
hi post increment problem
hi members,
I have a problem regarding Post increment operator.
public class aruntest {
public static void main(String args[])
{
int i=10;
i=i++;
System.out.println(i); // output is 10
}
}
I am not getting why the out put is 10. because i=i++; first i is assigned a value 10 then i is incremented by one, so it should be 11. but it print value 10. why can you explain.
- 11-13-2007, 11:59 AM #4
Arun, this is the wrong forum. Please repost your question to the appropriate forum.
- 11-13-2007, 12:29 PM #5
Member
- Join Date
- Nov 2007
- Location
- chengdu china
- Posts
- 1
- Rep Power
- 0
i++ and ++i
you should make clear the difference between i++ and ++i,
when you use i=i++,the value change (the increment) after the Assignment.it's true the value not changed.
if you you use i=++i,the value change (the increment) before the Assignment.so the value will change to 11.
sorry ! i am poor in english!


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks