next up previous
Next: Static methods Up: Unit 02 Previous: Evaluation of the expression

Evaluation of the expressions denoting the parameters of a method

What does the following statement print?

System.out.println("xxx".concat("yyy".concat("zzz")));

To provide an answer, we have to understand how the expression "xxx".concat("yyy".concat("zzz")) is evaluated.

  1. It is possible to evaluate immediately the subexpression "yyy".concat("zzz")

  2. After having evaluated "yyy".concat("zzz"), we can continue with "xxx".concat(...)

Hence, the statement System.out.println("xxx".concat("yyy".concat("zzz"))); prints "xxxyyyzzz".

The evaluation of the expressions denoting the parameters is done from the inside to the outside, computing each time the parameters of each call before the call is evaluated.


next up previous
Next: Static methods Up: Unit 02 Previous: Evaluation of the expression