For example:
int a = 10;
a += 1.5;
This runs perfectly, but
a = a+1.5;
this assignment says Type mismatch: cannot convert from double to int
.
So my question is: what is the difference between += operator
and = operator
. Why the first assignment didn't says nothing, but second will. Please explain to me. Just I want to know whether I can use the first assignment to all place or not.