• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Having doubt to understand the given answer/explanation

 
Rajesh k Jha
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Marshal
Pie
Posts: 21005
77
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15216
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic