The problem here involves type casting.
When you add int and long,
- The int object is casted to long & both are added and you get long object.
- but long object cannot be implicitly casted to int. So, you have to do that explicitly.
But +=
is coded in such a way that it does type casting. i=(int)(i+m)