Java convert boolean to string using String.valueOf() method
package com.w3spoint;
public class BooleanToString {
public static void main(String args[]){
boolean var = true;
//convert boolean to string
String str = String.valueOf(var);
System.out.println("String is: "+str);
}
} |
package com.w3spoint; public class BooleanToString {
public static void main(String args[]){
boolean var = true;
//convert boolean to string
String str = String.valueOf(var);
System.out.println("String is: "+str);
}
}
Output:
Download this example.
Java convert boolean to string using Boolean.toString() method
package com.w3spoint;
public class BooleanToString {
public static void main(String args[]){
boolean var = true;
//convert boolean to string
String str = Boolean.toString(var);
System.out.println("String is: "+str);
}
} |
package com.w3spoint; public class BooleanToString {
public static void main(String args[]){
boolean var = true;
//convert boolean to string
String str = Boolean.toString(var);
System.out.println("String is: "+str);
}
}
Output:
Download this example.