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