+= addition assignment operator casting in java

+= addition assignment operator casting in java

When we use addition assignment operator(+=),
We need to pay attention to the data type.

if the data types are different, implicit type-casting will be used:

refer‮ot ‬:lautturi.com
int a = 2;

a += 3.14;

a = 5

If we use + operator,it won't compile!

Type mismatch: cannot convert from double to int:

int a = 2;

a = a + 3.14;
Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
	Type mismatch: cannot convert from double to int
Created Time:2017-08-29 16:22:13  Author:lautturi