If the method's return type is something other than void, then a return statement must be at the end of each possible execution path within the method.

For example, if the method includes an "if" statement, then there must be a return statement for both cases -- that is, whether the "if" code executes or not.

If the method's return type is void, then no return statement is needed. (It's implicit at the end of the method body.) [ April 11, 2006: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummersscce.org

Jean Fore
Ranch Hand

Joined: Feb 23, 2006
Posts: 33

posted Apr 11, 2006 11:59:00

0

I have a callable statement declared locally in a method and I need to close this stament after it executes plus I need to return one of the values from the callable statment. So I need to write something like this :

Thanks Marc, But after closing the callable statement "rs.close()", can I get values from that 'rs' using "rs.getInt(1)"? The statement is already closed right? That's why I was asking about interchanging the code lines. Thanks -JEAN

There are two solutions that I can see here. The first is to create a temporary variable that you use to store the value returned by the getInt() method. Then you can call close() and then return the temporary variable. The second is to use a try...finally statement and call close() in the finally clause. This solution uses some knowledge of exception handling and may be more complex than needed. On the other hand, it also ensures that close() will be called whether or not an exception is thrown.