Java Java Basics Perfecting the Prototype Censoring Words - Using Logical ORs

when it true or false

Hello, i actually didn't really get it when it true or when it false?

does somebody can explain it to me please?

Mark Casavantes
Mark Casavantes
Pro Student 13,401 Points

Hi Yadin,

You use true and false when you are using boolean variables.

I am not sure what you mean by "it".

== Returns true if the expression on the left evaluates to the same value as the expression on the right. != Returns true if the expression on the left does not evaluate to the same value as the expression on the right. < Returns true if the expression on the left evaluates to a value that is less than the value of the expression on the right. <= Returns true if the expression on the left evaluates to a value that is less than or equal to the expression on the right.

Returns true if the expression on the left evaluates to a value that is greater than the value of the expression on the right. = Returns true if the expression on the left evaluates to a value that is greater than or equal to the expression on the right.

In this sample uses boolean and true/false.

boolean user = true;

if ( user == true) {
System.out.println("it's true");
}
else {
System.out.println("it's false");
}

If you have other questions, please let me know.

Happy Coding,

Mark

2 Answers

Jennifer Nordell
STAFF
Jennifer Nordell
Treehouse Staff

Hi there! In an "OR" statement, if any one of the expressions is true the entire thing will evaluate to true. In an "AND" statement every one of the expressions must be true for the entire thing to evaluate to true.

Hope this helps!

thank you very much all! :)