Page 292 of Head First
Java discuss static utility methods that are present in Wrapper classes. For example
int x = Integer.parseInt("2");
No problems with this example. It also gives the following example in case of Boolean:
boolean b = new Boolean("true").booleanValue();
Here, book mentions, the Boolean constructor takes and parses the
String and primitive variable 'b' gets the primitive value by unwrapping it. I cannot make sense out of this code. To me, the code should be:
boolean b = (new Boolean("true")).booleanValue();
The above two pieces give similar results, but I can understand the second implementation which tells me that we are calling the unwrap method on an object. Whereas the code mentioned in the book makes little sense to me.
Any help will be appreciated. Thanks.