aspose file tools*
The moose likes Beginning Java and the fly likes return type question? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "return type question?" Watch "return type question?" New topic
Author

return type question?

Elahe Shafie
Ranch Hand

Joined: Dec 12, 2001
Posts: 291
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
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
Thank you Dirk got it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: return type question?