Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Methods returning objects  RSS feed

 
SwetaSweta Singh
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to java.
I am unable to understand how methods return objects? Request some to explain with an example and with the outputs.

Thanks a tonne to the respondent and a detailed explaination will be much appreciated.

Sweta
[ December 12, 2008: Message edited by: SwetaSweta Singh ]
 
Campbell Ritchie
Marshal
Posts: 56529
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

All you have to do is to name the kind of Object you are returning. Just like these examples from the Java� Tutorials, only with different return types.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would say that methods don't really return objects. They return references to objects. It's kind of like saying "Where do you live", and I give you my address. I don't give you my actual house.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!