String Operators

Use the concatenation operator (+) to concatenate two string values together and a return another string that is the union of the two operand strings. For example, "my " + "string" returns the string "my string".

The shorthand assignment operator += can also be used to concatenate strings. For example, if the variable mystring has the value “alpha,” then the expression mystring += "bet" evaluates to “alphabet” and assigns this value to mystring.

The following table describes the string operators.

OperatorDescription

+

(String addition) Concatenates two strings.

+=

Concatenates two strings and assigns the result to the first operand.