What is the BooleanUtils.isFalse method in Java?
The isFalse static method of the BooleanUtils class can be used to check if the Boolean value passed is equal to false.
Syntax
public static boolean isFalse(Boolean bool);
Argument
The isFalse method takes the Boolean object as an argument.
Return value
This method returns true if the passed argument is equal to false. Otherwise, false is returned. If we pass null then false is returned.
Import BooleanUtils
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-langpackage, refer to the Maven Repository.
Possible case
BooleanUtils.isFalse
Case | Result |
BooleanUtils.isFalse(Boolean.TRUE) | false |
BooleanUtils.isFalse(Boolean.FALSE) | true |
BooleanUtils.isFalse(null) | false |
Code
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}}
Explanation
In the code above:
- On line, 1 we imported the
BooleanUtilsclass.
import org.apache.commons.lang3.BooleanUtils;
- From lines 5 to 8, we used the
isFalsemethod to check if the passed argument is false. - Below is the output.
BooleanUtils.isFalse(Boolean.TRUE); // false
BooleanUtils.isFalse(Boolean.FALSE); // true
BooleanUtils.isFalse(null); // false