Java Boolean.valueOf(boolean b)

Syntax

Boolean.valueOf(boolean b) has the following syntax.

public static Boolean valueOf(boolean b)

Example

In the following code shows how to use Boolean.valueOf(boolean b) method.


/*from  w w  w . j  a  v  a2s  .  c  om*/

public class Main {

   public static void main(String[] args) {
      boolean bool1 = true;
      boolean bool2 = false;
      Boolean b1 = Boolean.valueOf(bool1);
      Boolean b2 = Boolean.valueOf(bool2);

      System.out.println( b1 );
      System.out.println( b2 );
   }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable