Boolean.getBoolean("true") returns false

Boolean.getBoolean()'s argument expects the name of a system property. What you're looking for is Boolean.valueOf("true")


The method getBoolean takes a System Property name as an argument, not the String value of the boolean. What you need is probably Boolean.parseBoolean().


Boolean.getBoolean("true") has this javaDoc:

Returns true if and only if the system property named by the argument exists and is equal to the string "true". (Beginning with version 1.0.2 of the JavaTM platform, the test of this string is case insensitive.) A system property is accessible through getProperty, a method defined by the System class. If there is no property with the specified name, or if the specified name is empty or null, then false is returned.

You are looking for Boolean.valueOf("true")

Tags:

Java