+ 6
Is float i=2.5; correct in java?
4 Respuestas
+ 22
there will be loss of precision while converting double to float [2.5 is treated as a double type value]
//to prevent that U can write :::
⚫float i=(float)2.5; //typecasted from double to float
⚫float i=2.5f; //its in float
+ 13
I agree
+ 5
add f to the end
float i =2.5f;
+ 1
add f with it, otherwise it will be threaten as a double value and will produce an error