Computer Applications
What is wrong with the following statement?
float flt = 7895.0345;
Values & Data Types Java
17 Likes
Answer
This statement is trying to assign a double literal to a float variable so it will result in a syntax error of incompatible types (possible lossy conversion from double to float). To fix it we need to a f or F at the end of the double literal to make it a float literal as shown below:
float flt = 7895.0345f;
Answered By
13 Likes