Consider the scenario below:
public class ClassA {
private Main main;
Object obj = new Object;
public void setMain(Main main) {
this.main = main;
}
methodA() { //called first
obj.someFunction();
main.someFunction();
}
methodB() { //called second
obj.someOtherFunction();
}
}
Would methodB be using the same instance of "obj" as methodA? If not, how could the code be altered to make it so?
I apologize for such a basic question, but it is a concept that has been unclear for me since I started learning java, even after countless searches online.