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?
Float numbers you need to append '
f
' or 'F
' at end of the number like thisFloat f=1f;
orFloat f=1F
;