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

@return

Lenny Peter
Ranch Hand

Joined: Apr 22, 2008
Posts: 52
Hi
Should I have return if I have jMembership = 1600?




Thanks

When can I use only void get and when can I use both get and set in a class?
public getName()
public setName()
??
[ May 16, 2008: Message edited by: Leni Kravitskki ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

A "get" method returns something (a value or reference), so it cannot have a return type of void.

As for when to use get/set... It depends entirely on whether you want to make these features available outside the class.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Prasad Tamirisa
Ranch Hand

Joined: Mar 26, 2007
Posts: 130
You either change your return type or return nothing.


Regards,
Durga Prasad
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Prasad Tamirisa:
...or return nothing.

Returning nothing will allow it to compile, but then what is the method "getting"?
 
jQuery in Action, 2nd edition
 
subject: @return