Open In App

Boolean toString() Method in Java

Last Updated : 11 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

In Java, the toString() method of the Boolean class is a built-in method to return the Boolean value in string format. The Boolean class is a part of java.lang package. This method is useful when we want the output in the string format in places like text fields, console output, or simple text formatting.

Example 1: Using the Boolean.toString() method to get the object value in a string.

Java
// Java program to demonstrate 
// Boolean toString() method 
class Geeks
 { 
	public static void main(String[] args) 
	{ 
		// boolean type value 
		boolean value = true; 

		// static toString() method of Boolean class 
		String output = Boolean.toString(value); 

		// printing the value 
		System.out.println(output); 
	} 
} 

Output
true

Syntax of toString(boolean b) Method

public static String toString(boolean b)

  • Parameter: It takes a single boolean parameter (b) the value we want to convert into a string ( true or false ).
  • Return: It returns a string representation of the boolean value passed in it ("true" or "false").

Example 2: Using Boolean.toString() method to convert false boolean value to its string representation.

Java
// Java program to demonstrate 
// Boolean toString() method 
class Geeks
{ 
	public static void main(String[] args) 
	{ 
		// boolean type value 
		boolean value = false; 

		// static toString() method of Boolean class 
		String output = Boolean.toString(value); 

		// printing the value 
		System.out.println(output); 
	} 
} 

Output
false

Practice Tags :

Similar Reads

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy