How to check if String value is Boolean type in Java?

  • parseBoolean(String) returns true if the String is (case-insensitive) “true”, otherwise false
  • valueOf(String) ditto, returns the canonical Boolean Objects
  • getBoolean(String) is a red herring; it fetches the System property of the given name and compares that to “true”

There exists no method to test whether a String encodes a Boolean; for all practical effects, any non-“true”-String is “false”.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)