Forums Register Login

Having doubt to understand the given answer/explanation

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
 

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
+Pie Number of slices to send: Send
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.
I knew I would regret that burrito. But this tiny ad has never caused regrets:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1926 times.
Similar Threads
doubt in Math.round function.
Hashcode and equals() coding
what is dereference?
Autoboxing- dereference a primitive
float doubt
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 07:13:19.