This example is from Whizlabs. This code wont compile. The reason they have given is at line 1 we are attempting to dereference the primitive type float. I even heard "deference" word first time. Can anyone please help me?
I know one such term 'dereferencing' with respect to 'C'/'C++' Pointers, which actually means 'taking out the value stored in a particular memory address being pointed to by this pointer value'.
If, p is a pointer to an integer and it can be used as follows.
Here, they would have meant to say the same 'unboxing' i think. As, boxing and unboxing are the means to convert your primitive to wrappers and vice versa.
does that help dolly shah? [ October 08, 2007: Message edited by: Raghavan Muthu ]
Variables do not hold objects. Instead, variables hold references to objects.
So myVariable is just a reference -- not the object itself. But in order to call a method, we need the actual object. The dot operator "dereferences" the variable and "gets" the object.
However, a primitive variable holds the actual value. It does not just reference it. Therefore, primitive variables cannot be dereferenced. So if you try to use the dot operator on a primitive variable, you will get the "cannot be dereferenced" error.
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org