Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Basics Perfecting the Prototype Using Logical ORs and ANDs

What is even the math behind this?

I don't understand the logic of the math.

1 Answer

andren
andren
28,558 Points

I'm not entirely sure what you mean by "logic behind the math" as this section does not center on math, but on logic operators. But I can provide an explanation of how the comparisons and conditional operators gets evaluated. If this is not what you were wondering about then please clarify your question a bit, and I'll try to provide a better answer.

Comparisons are evaluated to Booleans (True or False) simply based on whether the statement they form is actually correct or incorrect. For example 5 > 3 (5 greater than 3) would equal True due to the fact that 5 is in fact greater than 3. 4 < 2 (4 less than 2) would equal False because 4 is not less than 2.

Conditional operators like || (OR) and && (AND) evaluates to True or False based on what the conditions you provide to them evaluates to. For example 3 > 1 && 5 < 1 (3 greater than 1 AND 5 less than 1) would equal False because while the first condition is True, the second is False, and the AND operator will only return True if both conditions evaluates to True. The OR operator will evaluate to True if either of the conditions are true. So 3 > 1 || 5 < 1 would evaluate to True because the first condition is True.