title: Calling method in object from object within it
body: <p>I have the following problem, and no idea how to solve it. Let's say we have a class <code>classA</code>, and in this class is the main method creating an object of the class itself. Now we take another class, <code>classB</code>. In the constructor of <code>classA</code> we make an object of <code>classB</code>. Now in a method of <code>classB</code> we want to call a method of <code>classA</code>.</p>
  
  <p>Let me provide you with an example.</p>
  
  <pre><code>public class classA {
      public classA() {
          //some code
          classB objectB = new classB();
      }
  
      public static void main(String[] args) {
          classA objectA = new classA();
          //more code
      }
  
      public void methodA() {
          //even more code
      }
  }
  
  public class classB {
      public void someListener() {
          //code needed to call methodA of the object objectA
      }
  }
  </code></pre>
  
  <p>The question is: what would the code be, where there is now just the comment <code>//code needed to call methodA of the object objectA</code>?</p>
  
  <p>The reason I'm in this situation, is that in the code that I'm going to use it for, there are various methods running in <code>objectB</code> controlled by loops, but once a certain thing happens a method in what is shown here as <code>objectA</code> has to be called. How do I do this?</p>