In the course of writing some throw-away code, I ran into a weird problem with static methods. I've defined a static method that's supposed to return a Double
, but Java insists that it's returning some new type named after the function.
Static method:
public class Temperature {
// ...
public static double CtoF( double c ) { return c * 1.8 + 32; }
// ...
}
Call, outside of Temperature
:
double temp = Temperature.CtoF( celsius );
Results in:
incompatible types
found: Temperature.CtoF
required: double
Any ideas?
EDIT: Never mind, it was a silly mistake on my part; I forgot that
celsius
[icode]
was not itself a
[icode]
Double
. Replacing the call with
double temp = Temperature.CtoF( new Double( celsius ) );
fixed the problem.