A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/java/boolean-tostring-method-in-java/ below:

Boolean toString() Method in Java

Boolean toString() Method in Java

Last Updated : 11 Jul, 2025

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); 
	} 
} 
Syntax of toString(boolean b) Method

public static String toString(boolean b)

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); 
	} 
} 


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4