Convert string to boolean

static boolean parseBoolean(String s)
Parses the string argument as a boolean.
static Boolean valueOf(boolean b)
Returns a Boolean instance representing the specified boolean value.
static Boolean valueOf(String s)
Returns a Boolean with a value represented by the specified string.

public class Main {
 
    public static void main(String[] args) {
     System.out.println(Boolean.parseBoolean("true"));
     System.out.println(Boolean.valueOf("true"));
    }
}

The output:


true
true
Home 
  Java Book 
    Essential Classes  

Boolean:
  1. Boolean class
  2. Get boolean value from constants in Boolean class
  3. Convert to primitive boolean value
  4. Use Boolean value constructors
  5. Compare two boolean values
  6. Get system property in boolean value
  7. Convert string to boolean
  8. Convert boolean to string