Author
return type question?
Elahe Shafie
Ranch Hand
Joined: Dec 12, 2001
Posts: 291
posted May 29, 2002 12:07:00
0
Friends, If a method's type is void do we need to have retun at the end like update method as bellow? public void update( Connection conn ) throws SQLException { int nUserId; int nStatusId; nStatusId = StatusTable.lookupName( conn, status ); nUserId = UserTable.lookupUserInitials( conn, userInitials ); PreparedStatement stmt = conn.prepareStatement("update bug set ID=?,bdesc=?,fixedDate=?,userID=?,contact=? where bugNumber=?"); stmt.setInt(1,nStatusId); stmt.setString(2,desc); stmt.setDate(3,fixedDate); stmt.setInt(4,nUserId); stmt.setString(5,contact); stmt.setInt(6,bugNumber); stmt.executeUpdate(); stmt.close(); return; }
Thanks,
Elahe
Dave Harpster
Greenhorn
Joined: Apr 11, 2002
Posts: 7
No you do not. dave
Elahe Shafie
Ranch Hand
Joined: Dec 12, 2001
Posts: 291
posted May 29, 2002 12:32:00
0
Dave, Thanks for the answer and just one last question that why I put return and compiler didn't give me error and it works fine? Thanks, Elahe
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
Because you are allowed to specify that you want the method to end now and return control to whomever had it before, but don't return some value.
[How To Ask Good Questions ] [JavaRanch FAQ Wiki ] [JavaRanch Radio ]
Elahe Shafie
Ranch Hand
Joined: Dec 12, 2001
Posts: 291
posted May 29, 2002 14:57:00
0
Thank you Dirk got it.
subject: return type question?