Convert a boolean value to String
We can use the Boolean wrapper class for converting the boolean value to String.
public class BooleanWrapper {
public static void main(String[] args) {
boolean bool = true;
String str = Boolean.toString(bool);
System.out.println(str);
}
}
or
public class BooleanWrapper {
public static void main(String[] args) {
boolean bool = true;
Boolean boolObject = Boolean.valueOf(bool);
String str = boolObject.toString();
System.out.println(str);
}
}
Tags: Boolean, Boolean examples, boolean to String, java.lang, java.lang.Boolean
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Leave a Reply