wood burning stoves 2.0*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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"?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: @return
 
Similar Threads
java.lang.IllegalAccessError
General Application Help
Why does this work? (apparent creation of an instance of an interface)
[Hibernate] Join without FK Relationship using Criteria
Comments on my first program to use an object