File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

@return

 
Lenny Peter
Ranch Hand
Posts: 52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Prasad Tamirisa
Ranch Hand
Posts: 130
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You either change your return type or return nothing.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Prasad Tamirisa:
...or return nothing.

Returning nothing will allow it to compile, but then what is the method "getting"?
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic