Java- Why the method argument treats the float value as double value?

casting, java

Solution

Java takes `10.1201` as `double`. In order to pass a `float` value you should append `f` to it like this:

float value =  methodReturnTest.getValue(10.1201f);

Problem

I've defined a method with one parameter of type float shown below: ``` public float getValue(float value){ return value; } ``` When I call this method by passing float value say 10.1201 shown below: ``` float value = methodReturnTest.getValue(10.1201); ``` My IDE says to cast the argument to float. I tried searching but couldn't get the appropriate answer. so posting it. Please explain . Thanks.

Original source

Related problems