English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
To get the string representation of a boolean value, usetoString()
Method.
Firstly, wevalueOf()
This method is used for the boolean object and sets a string value.
Boolean val = Boolean.valueOf("false");
Then use the 'toString()' method to represent the same content.
val.toString();
Let's see a complete example that prints the string representation of boolean values (True and False) in Java.
public class Demo { public static void main(String[] args) { //False Boolean val = Boolean.valueOf("false"); System.out.println("Displaying the string representation of Boolean"); System.out.println(val.toString()); //Correct val = Boolean.valueOf("true"); System.out.println(val.toString()); } }
Output Result
Displaying the string representation of Boolean false true