This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes One doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "One doubt" Watch "One doubt" New topic
Author

One doubt

Rajeswari Kumar
Greenhorn

Joined: Mar 23, 2007
Posts: 26
This is a question from whizlabs.

class AutoBox2 {
public static void main(String []ar) {
Float F=new Float(9.0);
float f=(float)9.0;
System.out.println(f.equals(F));
}
}
When I am trying to compile the program, following error has come
AutoBox2.java:6: float cannot be dereferenced
System.out.println(f.equals(F));
^
1 error
What is called dereferencing. But if it is given as
System.out.println(F.equals(f));
code compiles fine. Please explain me.
anil kumar
Ranch Hand

Joined: Feb 23, 2007
Posts: 447
Hi
kumar

Here f is primitive.How can you call a method on primitive variable ?

Thanks

Anil Kumar
Rajeswari Kumar
Greenhorn

Joined: Mar 23, 2007
Posts: 26
Yes Yes. Thanku. It didn't strike for me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: One doubt
 
Similar Threads
equals
about equals
what is dereference?
Having doubt to understand the given answer/explanation
float error