int a = 2;
int b = 3;
int c = 10;
a +=(a += b) + c; // this will be same as --> a = a+((a= a+b) +c);
/* 2+((2=2+3)+10)
after adding 2+3
now value a = 5;
5 +((5)+10)
5 + (15)
a = 20
*/
System.out.println("a: "+a); // a:17
when i execute above program the answer is a:17
why not a:20
?
according to me.
After resolving (a += b)
now the value of a
should be 5
then (a += b) + c
would be 15
and after that a +=(a += b) + c;
should be 20
please help me understand thanks.