Boolean booleanValue() method in Java with examples

The booleanValue() method of Boolean Class is a built in method in java which is used to return the primitive boolean value of instance which is used to call the method booleanValue().

Syntax

BooleanObject.booleanValue()

Return Value: It returns a primitive boolean value.



Below are the examples to illustrate booleanValue() method:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

class GeeksforGeeks {
  
    // Driver method
    public static void main(String[] args)
    {
  
        // creating a Boolean object.
        Boolean b = new Boolean(true);
  
        // get primitive data type using booleanValue()
        boolean value = b.booleanValue();
  
        // Print the result
        System.out.println(value);
    }
}

chevron_right


Output:

true

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

class GeeksforGeeks {
  
    // Driver method
    public static void main(String[] args)
    {
  
        // creating a Boolean object.
        Boolean b = new Boolean(false);
  
        // get primitive data type using booleanValue()
        boolean value = b.booleanValue();
  
        // Print the result
        System.out.println(value);
    }
}

chevron_right


Output:

false


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.