Java Data Type How to - Parse a String to a Boolean object


We would like to know how to parse a String to a Boolean object.


The static method valueOf parses a String to a Boolean object:

 public static Boolean valueOf (String string)
public class MainClass {

  public static void main(String[] args) {
    Boolean b = Boolean.valueOf("true");


The code above generates the following result.