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?
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