Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autoboxing - programming concept

1. public static void main(String[] args) 
2. {        
3.    Character s=1;
4.    Float f=1;
5. }

Both the lines 3 and 4 have a wrapper class and compiler performs autoboxing to convert 1 to Character but compiler cannot convert the same 1 to Float. Why?

like image 512
ec cap Avatar asked May 23 '26 17:05

ec cap


1 Answers

Float numbers you need to append 'f' or 'F' at end of the number like this Float f=1f; or Float f=1F;

like image 141
Prabhakaran Ramaswamy Avatar answered May 26 '26 06:05

Prabhakaran Ramaswamy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!