Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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
Courses Plus 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
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

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! :)