Java Basic Examples

Java convert String to boolean example

This example shows how to convert Java String to boolean in Java. This example also shows how to convert String to boolean primitive using Boolean wrapper class.

How to convert String to boolean in Java?

To convert String to boolean, use parseBoolean method of Java Boolean wrapper class.

This method returns boolean primitive value by parsing the input String value.


Important Note:

parseBoolean method returns true if the String value is not null and contains “true” ignoring the case. For every other values, parseBoolean method returns “false” boolean value.

Here are some of the example String values and their possible boolean output.

Please note that, parseBoolean returns “false” boolean value even for the empty String value (“”) and null.

Please let us know your views in the comments section below.

Want to learn quickly?
Try one of the many quizzes. I promise you will not be disappointed.


About the author



rahimv has over 15 years of experience in designing and developing Java applications. His areas of expertise are J2EE and eCommerce. If you like the website, follow him on Facebook, Twitter or Google Plus.

Add Comment

Your email address will not be published. Required fields are marked *