This is a very basic question, but I'd quite like an explanation of why my question can or cannot be achieved.
If I have a class (A) which contains say a string, with a set method for that string. And I instantiate another class (B) from the first class (A), why can't I then access the first class (A) from the new class (B) to call the set method for the string in the first class (A).
The only reason I ask is that I'm working on a project with a similar problem, from a main class I create a new class which returns some buttons. And when a button is clicked the ActionListener in the main class is supposed to change the String in the initial class, but I cannot seem to access the set Method of the original class without re-instantiating the class.
Sorry if that sounds rambled, but I really want to understand why this is an issue, and what the correct way of doing it is. I know I'll probably be shot down on this, but any help is appreciated.