This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

pass by reference problem?

 
harsh garg
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in pass by reference we generally pass class name and it's object,like this way can we pass interface and it's object?
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
harsh garg wrote:in pass by reference we generally pass class name and it's object,like this way can we pass interface and it's object?


you can declare interface reference as a parameter . and you can pass a object which implements the interface . and also you cant instantiate an interface

 
rakesh kumar nampally
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You can declare Interface and its reference in parameter list as , to this method you can send the object references which implement this Interface.

Thanks,
Rakesh.
 
Campbell Ritchie
Sheriff
Posts: 48402
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you pass by reference you aren't writing Java. Java works entirely on a pass-by-value basis. We have an FAQ about that. You can also do a search on this forum and you find all sorts of useful things about it, including my post in this thread, which has some useful links to other threads or resoures.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic