The isFalse
static method of the BooleanUtils
class can be used to check if the Boolean value passed is equal to false
.
public static boolean isFalse(Boolean bool);
The isFalse
method takes the Boolean
object as an argument.
This method returns true
if the passed argument is equal to false
. Otherwise, false
is returned. If we pass null
then false
is returned.
BooleanUtils
is defined in the Apache Commons Lang
package. Apache Commons Lang
can be added to the Maven project by adding the following dependency to the pom.xml
file.
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
For other versions of the
commons-lang
package, refer to the Maven Repository.
Case | Result |
BooleanUtils.isFalse(Boolean.TRUE) | false |
BooleanUtils.isFalse(Boolean.FALSE) | true |
BooleanUtils.isFalse(null) | false |
In the code below, we have used the isFalse
method as follows.
import org.apache.commons.lang3.BooleanUtils;class ISFalseExample {public static void main( String args[] ) {System.out.println("BooleanUtils.isFalse(Boolean.TRUE) => " + BooleanUtils.isFalse(Boolean.TRUE)); // falseSystem.out.println("BooleanUtils.isFalse(Boolean.FALSE) => " + BooleanUtils.isFalse(Boolean.FALSE)); // trueSystem.out.println("BooleanUtils.isFalse(null) => " + BooleanUtils.isFalse(null)); // false}}
In the code above:
BooleanUtils
class.import org.apache.commons.lang3.BooleanUtils;
isFalse
method to check if the passed argument is false.BooleanUtils.isFalse(Boolean.TRUE); // false
BooleanUtils.isFalse(Boolean.FALSE); // true
BooleanUtils.isFalse(null); // false