0

I have a very basic question regarding the inner workings or java. lets say we have a following statement

e.fld = expr;

where e is some class having a field fld. and expr is any java expression.

My question is that whether expr will be evaluated first or e will be evaluated first.

Usman
  • 781
  • 1
  • 6
  • 10
  • This seems like an easy enough thing to just test – glennsl Sep 27 '17 at 04:24
  • 1
    Java always evaluates expressions from left to right, so `e` is first. – 4castle Sep 27 '17 at 04:24
  • 1
    Java Language Spec, [§15.26](https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-Assignment): the expression on the left-hand size is evaluated before the expression on the right-hand side. – Kevin Anderson Sep 27 '17 at 04:35
  • thank you. that answered my question. I completely forgot 'e.fld = expr' itself is also an expression. – Usman Sep 27 '17 at 04:40

0 Answers0