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.

Maybe you have an out-of-date .class file for Temperature, or that file isn't in the classpath when you execute your other class?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.