Because every path out of the function has to return a value. Add a "return 0" to the catch, or, perhaps better, don't catch the exception, but let it propagate to tell the caller that no value could be returned.
thanks guys! so far i have added "return 0;" on the catch. and it works fine. but i got another error when i write :
GUI.java [149:1] cannot resolve symbol symbol : variable maks location: class GUI String stringMaks = Double.parseDouble(maks); ^ GUI.java [149:1] incompatible types found : double required: java.lang.String String stringMaks = Double.parseDouble(maks); ^ 2 errors
it says that it cannot resolve symbol? but "maks" has been returned back..
Joined: Apr 06, 2004
it says that it cannot resolve symbol? but "maks" has been returned back.. No, the value of maks has been returned, not maks itself. If you want to do something with that value, you have to store it like this: double x = finnMaks(f); There's another problem here: String stringMaks = Double.parseDouble(maks); Double.parseDouble() makes a double from a string, this is not what you want - you really want the opposite, and I'm not sure but it has to be something like this: Double d = new Double(x); String stringMaks = d.toString(); HTH [ April 13, 2004: Message edited by: Tobias Hess ]