jQuery in Action, 3rd edition
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


Lenny Peter
Ranch Hand

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


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

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
Prasad Tamirisa
Ranch Hand

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

Durga Prasad
marc weber

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"?
I agree. Here's the link: http://aspose.com/file-tools
subject: @return
It's not a secret anymore!