aspose file tools*
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
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: 18717
    
  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: 14111
    
  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
 
jQuery in Action, 2nd edition
 
subject: Having doubt to understand the given answer/explanation