@cham_gss: "class MainClass {
   static public int main(String[] args) {
     MainClass a = new MainClass();		// < here!
     OtherClass b = new OtherClass();
   }
   ..................
}
class OtherClass {
   private void aMethod() {
     MainClass f = getMainObject();		// < and here!
   }
}
-
Can you implement "getMainObject()" to return the "a"?
(a instanceof MainClass)
thanks"
    @oscar: "<quote>
No. But this is not necessary: it is always MainClass. Static methods are
always associated with the class in which they are defined, and not with a
subclass.
Just as non-static methods are always associated with the instance of the
class they are defined in, regardless of the (sub)class of the instance.
Oscar Kind                                    <url>
Software Developer                    for contact information, see website
PGP Key fingerprint:    91F3 6C72 F465 5E98 C246  61D9 2C32 8E24 097B B4E2"
    @matth: "news:clgjoa$52i$<email_address>
<quote>
No.  There is no information in OtherClass that ever contains the reference
to the same object referred to by "a". Somewhere, you must make the
reference what is referred to by "a" available to the OtherClass.  Some
options are:
1) Pass MainClass reference in to the OtherClass constructor.
2) Make a static variable in MainClass that is accessible to OtherClass,
3) Create a singleton class that is shared between MainClass and OtherClass
to hold the shared value.
The only way to know which of these (if any) or others is best is to know
exactly what problem you're trying to solve.
Cheers,
Matt Humphrey   <email_address>  <url>"
{'source': 'USENET', 'other_information': '{"reply_count": 2, "forum_name": "comp.lang.java.programmer.20150110.mbox"}', 'file': 'data/output/usenet-comp.lang.parquet'}