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.
I think that the above code with parentheses is more readable too. In other words "me too".
I disagree with the book using "true" as a String. This doesn't work for languages other than English. Using the string constructor for numbers is OK because they are the same in other languages, but using the String "true" instead of the boolean literal true is bad practice in general.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com