Assignment
= is the simple assignment operator. In assignment operations = is used differently from its normal algebraic use.
X=X+5 means that the variable X is 'assigned' the value that results from adding 5 to its existing value. So X becomes X+5.
Concatenation
The + operator can also be used to join strings together as was seen in an earlier example. This code sample shows how.
| //declare strings String str1 = "This string has "; String str2= "been concat"; String str3="enated."; //Join strings together String result = str1+str2+str3; //result = "This string has been concatenated." |
You can also concatenate a text string and a value to become a text string.
Increment and Decrement
Often in programming you want to add or subtract 1 from a variable. This happens so often that there are special operators for this.
x++; is equivalent to x=x+1;
y--; is equivalent to y=y-1;
You can also use incrementing in assignment operations.
z=x++ means that z is assigned the value of x, then x is incremented.
z=++x means that x is incremented, then the new value is assigned to z.

