• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Having doubt to understand the given answer/explanation

 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic