This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Having doubt to understand the given answer/explanation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Having doubt to understand the given answer/explanation" Watch "Having doubt to understand the given answer/explanation" New topic
Author

Having doubt to understand the given answer/explanation

Rajesh k Jha
Ranch Hand

Joined: May 10, 2009
Posts: 72
class Autobox2{
public static void main(String[] args){
Float A=9.0F;
float a=(float)9.0;
System.out.print(A.equals(a));
//System.out.print(a.equals(A));
System.out.print(a<=A);
System.out.print(A<=a);
}
}


The answer is given below, but i m unable to get it, can somebody explain it to me?

The above program show an error in line 6. The reason is that here we are attmpting to dereference the primitive type float, which is not allowed.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18743
    
  40

The above program show an error in line 6. The reason is that here we are attmpting to dereference the primitive type float, which is not allowed.


The float (primative) type don't have an equals() methods -- in fact, it doesn't have any methods.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14114
    
  16

Welcome to JavaRanch.

When you copy a question from a book, mock exam or other source, then you are required to quote your sources - so, please tell us where you copied this question from.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Having doubt to understand the given answer/explanation