aspose file tools
The moose likes Java in General and the fly likes Getting  the reference to an Enclosing Object from a reference to a object inside it. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Getting  the reference to an Enclosing Object from a reference to a object inside it." Watch "Getting  the reference to an Enclosing Object from a reference to a object inside it." New topic
Author

Getting the reference to an Enclosing Object from a reference to a object inside it.

N Naveen
Greenhorn

Joined: Sep 04, 2003
Posts: 27
Hi,
I have the following requirement.


Thanks in advance,
Naveen N
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24041
    
  13

No, it's not possible, except by changing the method signature of method1 so you can pass it in as an argument.


[Jess in Action][AskingGoodQuestions]
Andris Jekabsons
Ranch Hand

Joined: Jan 20, 2004
Posts: 82
I agree that it is best to modify method1() signature, but isn't it possible to add a static variable "X dummy" to the ABC class and then reference it from the method1()? Sure it would be shared by all ABC objects, but that's ok, because it is already shared, since main() is static, too.
Here is a modified code:
N Naveen
Greenhorn

Joined: Sep 04, 2003
Posts: 27
I dont wish to change it to a static variable.
Though the main method is static,the variable is still a local variable.
Thanks a lot for replying.
I guess its not possible.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting the reference to an Enclosing Object from a reference to a object inside it.
 
Similar Threads
Overload or Override?
Static Inner Class
does every object have its own method
abstract class instantiation
Adding component in JPanel