> Here's the code
>
[quoted text clipped - 16 lines]
>
> Why += version working?
"A compound assignment expression of the form E1 op= E2 is equivalent to
E1 = (T)((E1) op (E2)), where T is the type of E1, except that E1 is
evaluated only once."
[http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#5304]
Your += is equivalent to:
b = (int)((b) + (r*10.0));
except for only evaluating b once, which makes no difference because
evaluating b has no side effects.
The line that gives the error does not have the (int) cast that is
implied by the +=.
Patricia
Kavya - 28 Oct 2006 02:18 GMT
> > Here's the code
> >
[quoted text clipped - 32 lines]
> The line that gives the error does not have the (int) cast that is
> implied by the +=.
Thank You.