Page 1 of 1

About Question enthuware.ocajp.i.v8.2.1111 :

Posted: Thu Mar 24, 2016 12:41 am
by Sergio
boolean b1 = false;
boolean b2 = false;
if (b2=b1==false)

which is the operation that is executed first?

Re: About Question enthuware.ocajp.i.v8.2.1111 :

Posted: Thu Mar 24, 2016 9:55 am
by admin
As per https://docs.oracle.com/javase/specs/jl ... l#jls-15.2
assignment operator = has lower precedence than ==. Therefore, the given expression is same as:
b2 = (b1==false)
HTH,
Paul.

Re: About Question enthuware.ocajp.i.v8.2.1111 :

Posted: Sat Feb 25, 2017 11:16 am
by AndaRO
[quote="admin"]As per https://docs.oracle.com/javase/specs/jl ... l#jls-15.2
assignment operator = has lower precedence than ==. Therefore, the given expression is same as:
b2 = (b1==false)
(which is the Left Hand Side of the expression), it returns true, which is again a boolean.
[quote]

true is right side of the expression.