Hello! The explanation states that "Comparison operators have lower precedence than mathematical operators."
But what if we have something like this:
int x1 = 50, x2 = 75;
boolean b = x1 >=x2;
Is it equal to boolean (b = x1) >=x2; or to boolean b = (x1 >=x2);?
What will be evaluated first: the comparison or assigning x1 value to b?
About Question enthuware.ocajp.i.v8.2.1408 :
Moderator: admin
-
- Posts: 1
- Joined: Sun Feb 13, 2022 12:55 pm
- Contact:
-
- Site Admin
- Posts: 10055
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1408 :
= is not a mathematical operator, so, why do you think it can be boolean (b = x1) >=x2; ?
= is an assignment operator and has the lowest precedence out of all (except lambda).
You may want to go through this article to understand the basics of expression evaluation:
https://enthuware.com/oca-ocp-java-cert ... evaluation
= is an assignment operator and has the lowest precedence out of all (except lambda).
You may want to go through this article to understand the basics of expression evaluation:
https://enthuware.com/oca-ocp-java-cert ... evaluation
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 55 guests