aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Autoboxing- dereference a primitive Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Autoboxing- dereference a primitive" Watch "Autoboxing- dereference a primitive" New topic
Author

Autoboxing- dereference a primitive

Santiago Bravo
Ranch Hand

Joined: Jul 25, 2008
Posts: 226
Following taken from whizlabs:





The answer is that Line 2 causes a compiler error as there is an attempt to reference the primitive type float.

I thought autoboxing will take care of line 2 it will compile and run ok.


Can anyone explain what is meant by dereferncing the primitive?

Thanks


Santiago
My Path to SCJP Certification My Path to SCWCD Certification
Paul Campbell
Ranch Hand

Joined: Oct 06, 2007
Posts: 338
You're asking the compiler to autobox and call the objects method... that is just something that isn't going to happen... just like it won't widen a primitive and then autobox (but it will box and then widen to object.

To do what you want it to do... you would have to have something like the following at Line 2:

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Autoboxing- dereference a primitive