Home » Java programming language

Java Boolean class getBoolean() method with example

Boolean class getBoolean() method: Here, we are going to learn about the getBoolean() method of Boolean class with its syntax and example.
Submitted by Preeti Jain, on October 25, 2019

Boolean class getBoolean() method

  • getBoolean() method is available in java.lang package.
  • getBoolean() method is used to return the system property in boolean values either true or false.
  • getBoolean() method is a static method, it is accessible with the class name too and if we try to access the method with the class object then also we will not get an error.
  • getBoolean() method does not throw an exception at the time of returning system property.


    public static boolean getBoolean(String sys_prop);


  • String sys_prop – represents the string value (system _property) to be parsed.

Return value:

The return type of this method is boolean - it returns the corresponding boolean value that represent the String value.

Note: If the given argument system_property exists and the value is equal to true, it returns true.


// Java program to demonstrate the example 
// of getBoolean(String sys_prop) method of Boolean class

public class GetBooleanOfBooleanClass {
    public static void main(String[] args) {
        String sys_prop1 = "Is Java8 exists";
        String sys_prop2 = "Is C++ not support OOPS";

        // By setting property value by using 
        // setProperty(propertyname , value) method
        System.setProperty(sys_prop1, "true");
        System.setProperty(sys_prop2, "false");

        // Store result in boolean variables
        boolean b1 = Boolean.getBoolean(sys_prop1);
        boolean b2 = Boolean.getBoolean(sys_prop2);

        // Display result
        System.out.println("Boolean.getBoolean(sys_prop1): " + b1);
        System.out.println("Boolean.getBoolean(sys_prop2): " + b2);


Boolean.getBoolean(sys_prop1): true
Boolean.getBoolean(sys_prop2): false

Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.