Java Reference
In-Depth Information
Logical Operators
A logical operator can be used with any primitive value or object. The results are based on
whether the values are considered to be truthy or falsy.
! (Logical NOT)
Placing the ! operator in front of a value will convert it to a Boolean and return the opposite
value. So truthy values will return false , and falsy values will return true . This is known
as negation :
<< false
<< true
You can use double negation ( !! ) to find out if a value is truthy or falsy (it is a shortcut to
using the Boolean function we employed earlier because you are effectively negating the
<< false
<< true
<< true
<< false
<< true
Search WWH ::

Custom Search