When answering this question I was in doubt:
will b2 = b1 first be evaluated and then the rest of the expression which then become b2 != b2,
or will b1 != b2 first be evaluated putting the result in b2.
With b1 and b2 both being false the result is the same, but if b1 had been true initially it would have been different.
I answered correct but don't know the real rule with such expressions. Can you provide that?
About Question com.enthuware.ets.scjp.v6.2.701 :
Moderator: admin
-
- Posts: 50
- Joined: Sun Nov 10, 2013 4:39 am
- Contact:
-
- Site Admin
- Posts: 10405
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.701 :
Details of evaluation order are given here: http://docs.oracle.com/javase/specs/jls ... l#jls-15.7
and http://docs.oracle.com/javase/specs/jls ... ls-15.26.1
So you should group the given expression like this: b2 = (b1 != b2) rather than (b2 = b1) != b2
and http://docs.oracle.com/javase/specs/jls ... ls-15.26.1
So you should group the given expression like this: b2 = (b1 != b2) rather than (b2 = b1) != b2
Who is online
Users browsing this forum: Google [Bot] and 10 guests