Yes, it does. There is a constructor for Boolean which takes a literal. If the literal is "True" (case does not matter), the object wraps true. If it is something else (like "abcd") the object will wrap "false".
Hi the following are from JAVA API on Boolean class for valueOf methods. My question is when we send a string as parameter to Boolean.ValueOf method is the return value is one of Boolean.TRUE / Boolean.FALSE? If so like in ValueOF(boolean) why doesn't API specify the same?
public static Boolean valueOf(boolean b)Returns a Boolean instance representing the specified boolean value. If the specified boolean value is true, this method returns Boolean.TRUE; if it is false, this method returns Boolean.FALSE. If a new Boolean instance is not required, this method should generally be used in preference to the constructor Boolean(boolean), as this method is likely to to yield significantly better space and time performance. Parameters
public static Boolean valueOf(String s)Returns a Boolean with a value represented by the specified String. The Boolean returned represents the value true if the string argument is not null and is equal, ignoring case, to the string "true".
[ February 13, 2003: Message edited by: Sarma Lolla ] [ February 13, 2003: Message edited by: Sarma Lolla ] [ February 13, 2003: Message edited by: Sarma Lolla ]
It is often a nice and interesting expedition to go see the JDK source code. In this case, we have to look at the class java.lang.Boolean. Below is the constructor Boolean(String) constructor as well as one of the private toBoolean() method invoked within the body of the constructor.
Form the code we case see, as Piotr mentioned, that if the value of the given String object is "true" (whatever the case) then the Boolean object will wrap a true else a false. Remember: the answer is out there [ February 13, 2003: Message edited by: Valentin Crettaz ]