Basic Java Language: Difference between revisions
wikademia>Zchenyu |
wikademia>Zchenyu |
||
| Line 146: | Line 146: | ||
=== Addition Operator '+' === | === Addition Operator '+' === | ||
The addition operator is different from the = operator | The addition operator is different from the = operator in respect to the fact that it does not set anything. The addition operator returns the sum of the two values next to it. | ||
If you want to you want to use the addition operator to add 6 to the value of ''a'', | If you want to you want to use the addition operator to add 6 to the value of ''a'' and store that value back into ''a'', the following statement would be used: | ||
<pre>a = a + 6;</pre> | <pre>a = a + 6;</pre> | ||
You could also use the plus-equals operator to achieve the same result: | |||
<pre>a += 6;</pre> | <pre>a += 6;</pre> | ||
=== Subtraction '-', Division '/' and Multiplication '*' Operators === | === Subtraction '-', Division '/' and Multiplication '*' Operators === | ||