Hama Kamal wrote:
page 241 from the K&B book, it states:
The difference
between the two methods is
■ parseXxx() returns the named primitive. >>> it also returns object of the type that invoked
■ valueOf() returns a newly created wrapped object of the type that invoked >>> it also returns the named primitivethe method.
Here are some examples of these methods in action:
It doesn't
also returns object of the type or vice versa -- as you can't define a method to return both an Object and a primitive value.
Hama Kamal wrote:
the following is alos true
your comments please !
While those statements do compile, it doesn't mean that both primitives and objects are returned. What is happening is that autoboxing is taking place. The compiler will generate code to convert primitives with its wrapper type. Specifically, it does this to the code -- which you don't see.
Henry