Until today, I thought that for example:
i += j;
Was just a shortcut for:
i = i + j;
But if we try this:<
you need to cast from long
to int
explicitly
in case of i = i + l
then it will compile and give correct output. like
i = i + (int)l;
or
i = (int)((long)i + l); // this is what happens in case of += , dont need (long) casting since upper casting is done implicitly.
but in case of +=
it just works fine because the operator implicitly does the type casting from type of right variable to type of left variable so need not cast explicitly.