Results 1 to 5 of 5

Thread: hi

  1. #1
    Arun Singla is offline Member
    Join Date
    Nov 2007
    Posts
    2
    Rep Power
    0

  2. #2
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    10

    Default

    Hi Arun, welcome..

  3. #3
    Arun Singla is offline Member
    Join Date
    Nov 2007
    Posts
    2
    Rep Power
    0

    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.

  4. #4
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    10

    Default

    Arun, this is the wrong forum. Please repost your question to the appropriate forum.

  5. #5
    rock_yfp is offline Member
    Join Date
    Nov 2007
    Location
    chengdu china
    Posts
    1
    Rep Power
    0

    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •