Assignment

The assignment statement has a value identifier on left hand side, an = sign, a value expression on the right hand side and a semicolon. When the statement is run the right hand expression is evaluated and the result is stored in the variable named by the identifier. This example assign the integer value 1 to the variable named a.

a = 1;

Java and BeanShell also support a suite of increment-and-assign operators, such as +=, -=, *= and /=. These shortcut assignment operators modify the value on the left side by the value on the right side. For example, the following will set the value of a to 6.

a = 1;
a += 5;

This example will set the value of a to 25:

a = 5;
a *= 5;