Next page | Contents page |

Assignment statements

We have already seen examples. An expression is evaluated and the result is assigned to the variable on the left hand side:

   x *= 3.14;
   boolean checked = true;
   String fullName = firstName + " " + lastName;
   r2 = x * x + y * y;
   double r = squareRoot (r2);  // result of method

NB: Statements in Java are always evaluated from left to right:

	double r = function1 () + function2 ();

What if the functions change other values which each uses? In some languages the result is unpredictable!

Next page | Contents page |