Hello

I am here seeking knowledge of people who actually know what they are talking about.

In mobile development, specifically Andriod, is there any reason to use variable1 = variable1 + variable2 over variable1 += variable2 ?

This was a subject that came up recently and my lecturer simply said not to use += as it is slower and takes more processing power than the other method.

I have googled, but I am unable to find any information either way confirming or denying this, and when asked, the lecturer can provide no reasoning other than 'it just is'.

Based on other inaccuracies he is teaching, I am wondering if there is any truth is this.

Any help appreciated.

I guess you will need to ask him for some references on his claim as I believe he is wrong since following resource, which are for Java says otherwise

"You might expect that a += b; is identical to a = a + b; when the two are compiled, but that is not the case. In fact, these cause different Java bytecodes to be generated, and the second approach actually takes longer to execute. Therefore, you can make minor improvements in the speed of your code by using compound operators such as +=, -=, *=, and /=." Professional Java Programming.

Strength reduction pg 154-155, Practical Java - Programming Language Guide

commented: nice +9
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.