
- Java.lang Package classes
- Java.lang - Home
- Java.lang - Boolean
- Java.lang - Byte
- Java.lang - Character
- Java.lang - Character.Subset
- Java.lang - Character.UnicodeBlock
- Java.lang - Class
- Java.lang - ClassLoader
- Java.lang - Compiler
- Java.lang - Double
- Java.lang - Enum
- Java.lang - Float
- Java.lang - InheritableThreadLocal
- Java.lang - Integer
- Java.lang - Long
- Java.lang - Math
- Java.lang - Number
- Java.lang - Object
- Java.lang - Package
- Java.lang - Process
- Java.lang - ProcessBuilder
- Java.lang - Runtime
- Java.lang - RuntimePermission
- Java.lang - SecurityManager
- Java.lang - Short
- Java.lang - StackTraceElement
- Java.lang - StrictMath
- Java.lang - String
- Java.lang - StringBuffer
- Java.lang - StringBuilder
- Java.lang - System
- Java.lang - Thread
- Java.lang - ThreadGroup
- Java.lang - ThreadLocal
- Java.lang - Throwable
- Java.lang - Void
- Java.lang Package extras
- Java.lang - Interfaces
- Java.lang - Errors
- Java.lang - Exceptions
- Java.lang Package Useful Resources
- Java.lang - Useful Resources
- Java.lang - Discussion
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java.lang.Boolean.toString() Method
Description
The java.lang.Boolean.toString(boolean b) returns a String object representing the specified boolean. If the specified boolean is true, then the string "true" will be returned, otherwise the string "false" will be returned.
Declaration
Following is the declaration for java.lang.Boolean.toString() method
public static String toString(boolean b)
Parameters
b − the boolean to be converted
Return Value
This method returns the string representation of the specified boolean.
Exception
NA
Example
The following example shows the usage of lang.Boolean.toString() method.
package com.tutorialspoint; import java.lang.*; public class BooleanDemo { public static void main(String[] args) { // create 2 boolean primitives bool1, bool2 boolean bool1, bool2; // assign values to bool1, bool2 bool1 = true; bool2 = false; // create 2 String's s1, s2 String s1, s2; /** * static method is called using class name * assign string value of primitives bool1, bool2 to s1, s2 */ s1 = Boolean.toString(bool1); s2 = Boolean.toString(bool2); String str1 = "String value of boolean primitive " +bool1+ " is " +s1; String str2 = "String value of boolean primitive " +bool2+ " is " +s2; // print s1, s2 values System.out.println( str1 ); System.out.println( str2 ); } }
Let us compile and run the above program, this will produce the following result −
String value of boolean primitive true is true String value of boolean primitive false is false
java_lang_boolean.htm
Advertisements