boolean b1 = false;
boolean b2 = false;
if (b2=b1==false)
which is the operation that is executed first?
			
			
									
									
						About Question enthuware.ocajp.i.v8.2.1111 :
Moderator: admin
- 
				Sergio
 - Posts: 7
 - Joined: Wed Mar 23, 2016 1:39 am
 - Contact:
 
- 
				admin
 - Site Admin
 - Posts: 10443
 - Joined: Fri Sep 10, 2010 9:26 pm
 - Contact:
 
Re: About Question enthuware.ocajp.i.v8.2.1111 :
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.
			
			
									
									
						assignment operator = has lower precedence than ==. Therefore, the given expression is same as:
b2 = (b1==false)
HTH,
Paul.
- 
				AndaRO
 - Posts: 31
 - Joined: Wed Feb 08, 2017 5:42 pm
 - Contact:
 
Re: About Question enthuware.ocajp.i.v8.2.1111 :
[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.
			
			
									
									
						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.
Who is online
Users browsing this forum: No registered users and 10 guests