Java Convert Boolean To String Example

Easily convert datatype of type Boolean to datatype String using the Boolean.toString() method of the Integer class. This method will return a String object representing the specified boolean. The string will either be “true” or “false”.


Java Convert Boolean To String Source Code

package com.jcd.java.tutorials;

public class JavaBooleanToString 
{

	public static void main(String[] args) 
	{
		boolean jcdBoolean = true;
		
		String jcdString = Boolean.toString(jcdBoolean);
		
		System.out.println("Boolean as String: "+jcdString);
	}

}


Java Convert Boolean To String Output

Boolean as String: true


Add a Comment

Your email address will not be published. Required fields are marked *