java.lang.Boolean getBoolean(String name)


The getBoolean(String name) method of Boolean class returns true if and only if the system property named by the argument exists and is equal to the string “true”. (Beginning with version 1.0.2 of the JavaTM platform, the test of this string is case insensitive.) A system property is accessible through getProperty, a method defined by the System class.

If there is no property with the specified name, or if the specified name is empty or null, then false is returned.

Important Notes:

  • throws SecurityException – for the same reasons as System.getProperty

Method Syntax

public static boolean getBoolean(String name)

Method Argument

Data Type Parameter Description
Boolean b the Boolean instance to be compared

Method Returns

The getBoolean(String name) method of Boolean class the boolean value of the system property.

Java Boolean getBoolean(String name) Example

Below is a simple java example on the usage of getBoolean() method of Boolean class.

Basically on the above example, we have set a system property with boolean value and we used the getBoolean() method in getting the set value.

Sample Output

Below is the sample output when you run the above example.

java Boolean getBoolean() example output