源码如下:
/**
* Parses the string argument as a boolean. The {@code boolean}
* returned represents the value {@code true} if the string argument
* is not {@code null} and is equal, ignoring case, to the string
* {@code "true"}. <p>
* Example: {@code Boolean.parseBoolean("True")} returns {@code true}.<br>
* Example: {@code Boolean.parseBoolean("yes")} returns {@code false}.
*
* @param s the {@code String} containing the boolean
* representation to be parsed
* @return the boolean represented by the string argument
* @since 1.5
*/
public static boolean parseBoolean(String s) {
/**
String类型转boolean类型的一个方法
当String的值为“true”时返回true,(equalsIgnoreCase忽略大小写)
当为其他字符串时返回false。
*/
return ((s != null) && s.equalsIgnoreCase("true"));
}