CS 111 - 3/6/14
Boolean Operators - allow the program to combine
multiple boolean values together
Boolean Operator are most often used when we
need a complex condition statement
The 3 common Boolean Operators are
AND &&
OR ||
NOT !
The NOT operation, inverses the Boolean value
true ==> false
flase ==> true
boolean x = true;
boolean y;
y = !x;
An if statement the check if a value is
NOT less than 10, would be
if ( !(value1 < 10) )
{
....
}
AND takes two boolean values and results in a true
value if both values were originally true
Otherwise the result is false
if ( (brightness >= 192 ) && (brightness < 256))
{
....
}
OR takes two boolean values and results in a true
value if either value was originally true
Otherwise the result is false
if ( (w1 != w2) || (h1 != h2) )
{
....
}