HOME      BLOG       FORUMS      CONTACT       ABOUT

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

Share

Tags: , , , ,


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.

AddThis Social Bookmark Button

Leave a Reply