Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-13-2007, 11:51 AM
Member
 
Join Date: Nov 2007
Posts: 2
Rep Power: 0
Arun Singla is on a distinguished road
Default hi
Hi, This is Arun Singla.
New to this community
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-13-2007, 12:42 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
Rep Power: 10
JavaBean is on a distinguished road
Default
Hi Arun, welcome..
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-13-2007, 12:51 PM
Member
 
Join Date: Nov 2007
Posts: 2
Rep Power: 0
Arun Singla is on a distinguished road
Default 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.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-13-2007, 12:59 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
Rep Power: 10
JavaBean is on a distinguished road
Default
Arun, this is the wrong forum. Please repost your question to the appropriate forum.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 11-13-2007, 01:29 PM
Member
 
Join Date: Nov 2007
Location: chengdu china
Posts: 1
Rep Power: 0
rock_yfp is on a distinguished road
Cool 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!
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +2. The time now is 03:39 PM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org