Velocity Reviews > Java > Translate to english

# Translate to english

Tavish Muldoon
Guest
Posts: n/a

 08-23-2004
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.

Elie De Brauwer
Guest
Posts: n/a

 08-23-2004
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