- Java.lang Package classes
- Java.lang - Home
- Java.lang - Boolean
- Java.lang - Byte
- Java.lang - Character
- Java.lang - Character.Subset
- Java.lang - Character.UnicodeBlock
- Java.lang - Class
- Java.lang - ClassLoader
- Java.lang - Compiler
- Java.lang - Double
- Java.lang - Enum
- Java.lang - Float
- Java.lang - InheritableThreadLocal
- Java.lang - Integer
- Java.lang - Long
- Java.lang - Math
- Java.lang - Number
- Java.lang - Object
- Java.lang - Package
- Java.lang - Process
- Java.lang - ProcessBuilder
- Java.lang - Runtime
- Java.lang - RuntimePermission
- Java.lang - SecurityManager
- Java.lang - Short
- Java.lang - StackTraceElement
- Java.lang - StrictMath
- Java.lang - String
- Java.lang - StringBuffer
- Java.lang - StringBuilder
- Java.lang - System
- Java.lang - Thread
- Java.lang - ThreadGroup
- Java.lang - ThreadLocal
- Java.lang - Throwable
- Java.lang - Void
- Java.lang Package extras
- Java.lang - Interfaces
- Java.lang - Errors
- Java.lang - Exceptions
- Java.lang Package Useful Resources
- Java.lang - Useful Resources
- Java.lang - Discussion
Java - Boolean booleanValue() method
Description
The Java Boolean booleanValue() returns the value of this Boolean object as a boolean primitive.
Declaration
Following is the declaration for java.lang.Boolean.booleanValue() method
public boolean booleanValue()
Parameters
NA
Return Value
This method returns the primitive boolean value of this object.
Exception
NA
Example 1
The following example shows the usage of Boolean booleanValue() method.
package com.tutorialspoint; public class BooleanDemo { public static void main(String[] args) { // create a Boolean object b Boolean b; // assign value to b b = new Boolean(true); // create a boolean primitive type bool boolean bool; // assign primitive value of b to bool bool = b.booleanValue(); String str = "Primitive value of Boolean object " + b + " is " + bool; // print bool value System.out.println( str ); } }
Output
Let us compile and run the above program, this will produce the following result −
Primitive value of Boolean object true is true
Example 2
The following is another example to show the usage of Boolean booleanValue() method.
package com.tutorialspoint; public class BooleanDemo { public static void main(String[] args) { // create a Boolean object b Boolean b; // assign value to b b = Boolean.valueOf(false); // create a boolean primitive type bool boolean bool; // assign primitive value of b to bool bool = b.booleanValue(); String str = "Primitive value of Boolean object " + b + " is " + bool; // print bool value System.out.println( str ); } }
Output
Let us compile and run the above program, this will produce the following result −
Primitive value of Boolean object false is false
Example 3
The following is another example to show the usage of Boolean booleanValue() method.
package com.tutorialspoint; public class BooleanDemo { public static void main(String[] args) { // create a Boolean object b Boolean b; // assign value to b b = Boolean.valueOf(false); // create a boolean primitive type bool boolean bool; // assign a primitive value to Boolean object b = true; // assign primitive value of b to bool bool = b.booleanValue(); String str = "Primitive value of Boolean object " + b + " is " + bool; // print bool value System.out.println( str ); } }
Output
Let us compile and run the above program, this will produce the following result −
Primitive value of Boolean object true is true
java_lang_boolean.htm
Advertisements