Translate to english

Discussion in 'Java' started by Tavish Muldoon, Aug 23, 2004.

  1. Hello,

    Would someone be able to explain what the resultant would be of this statement:

    int i = 2;
    int j = 3;
    int k = 4;

    i += j += ++k;


    Would some one be able to translate this into 'english'?

    I see it as 'add 1 to k' which now equals 5
    then 'add 5 to j' which is 3+5=8
    then 'add 2' which is the value of i
    for a grand total of 10.

    Is this correct?

    Thanks,

    Tmuld.
    Tavish Muldoon, Aug 23, 2004
    #1
    1. Advertising

  2. On Mon, 23 Aug 2004 07:18:44 -0700, Tavish Muldoon wrote:

    > Hello,
    >
    > Would someone be able to explain what the resultant would be of this statement:
    >
    > int i = 2;
    > int j = 3;
    > int k = 4;
    >
    > i += j += ++k;
    >
    >
    > Would some one be able to translate this into 'english'?
    >
    > I see it as 'add 1 to k' which now equals 5
    > then 'add 5 to j' which is 3+5=8
    > then 'add 2' which is the value of i
    > for a grand total of 10.
    >
    > Is this correct?
    >


    k=k+1;
    // k = 5
    j= j + k;
    // j = 8
    i= i + k;
    // i = 10;

    You assumption was correct, but the easiest way to be sure is by coding it.

    my 2 cents

    --
    Elie De Brauwer
    http://www.de-brauwer.be

    No animals were hurt and no microsoft products were used during the
    creation of this e-mail
    Elie De Brauwer, Aug 23, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sridhar Hegde
    Replies:
    2
    Views:
    2,517
    Ajeetha Kumari
    Sep 13, 2004
  2. Tian Min Huang
    Replies:
    0
    Views:
    364
    Tian Min Huang
    Jul 23, 2003
  3. Aaron Lewis
    Replies:
    0
    Views:
    634
    Aaron Lewis
    Jul 23, 2003
  4. =?Utf-8?B?UmFlZCBTYXdhbGhh?=

    English/English DLL

    =?Utf-8?B?UmFlZCBTYXdhbGhh?=, Oct 15, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,670
    =?Utf-8?B?UmFlZCBTYXdhbGhh?=
    Oct 16, 2005
  5. IchBin
    Replies:
    1
    Views:
    768
Loading...

Share This Page