Skip to Content

Convert java Boolean object to String object Example

  1. /*
  2.   Convert java Boolean object to String object Example
  3.   This example shows how to convert java Boolean object into String object.
  4. */
  5.  
  6. public class JavaBooleanToStringExample {
  7.  
  8.   public static void main(String[] args) {
  9.     //construct Boolean object
  10.     Boolean blnObj = new Boolean("true");
  11.    
  12.     //use toString method of Boolean class to convert it into String
  13.     String str = blnObj.toString();
  14.     System.out.println(str);
  15.   }
  16. }
  17.  
  18. /*
  19. Output would be
  20. true
  21. */