I am starting to program in Java, and now I am working on an application with a more complex class structure and graphical interface. These may be silly questions, but it is very difficult for Google, so I ask here.
I have a main class that looks like this:
package app;
public class App {
private FirstClass fc;
private SecondClass sc;
public App () {
fc = new FirstClass ();
sc = new SecondClass ();
}
}
Say that SecondClass is defined outside of this .java file (e.g. GUI form). Is there any way to access the instance of "fc" (or other member variables of the application instance) from the instance of "sc" (without passing the pointer to "this")? Sort of:
class SecondClass {
public void someMethod() {
getWhoeverCreatedThisInstance().fc.getSomeData();
}
}
, ? -? , "fc" ? , , , ? - ? "this" "App" "fc" "SecondClass", , , , .
? !