+ 2
Difference between a=a+1 and a+=1
Is there any difference between a=a+1 and a+=1? Not in result But when the compiler compiles it
2 Respuestas
+ 1
a=+1 is completely different from a+=1. I think you made a very common typo there. Ignoring that, there is no difference between the both. a+=1 has always been regarded to be semantically the same as a=a+1.
+ 1
As both formats are same but the difference is in their execution...
According to Java and C..
As a=a+1 consist of two linear Operations of addition and assigning
Where as
a+=1 consist of both operations executing in parallel. That's the reason it's more preferred.