Java Data Type Tutorial - 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.

//  w w  w.  ja  v a 2s  .com

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.