Global objects in Java?
<p>I have two classes:</p>

<pre><code>public class A{
   int money;
   ArrayList&lt;Item&gt; boughtItems;
   .
   .
   public void addBoughtItem(Item item){
      .
      .
   }
   public void adjustMoney(int adjustAmount){
      money = money + adjustamount;
   }
}
</code></pre>

<p>and another class :</p>

<pre><code>public class B{
  ArrayList&lt;Item&gt; itemsForSale;
  .
  .
  public Item sellMeItem(Item item){
    .
    .
    return itemsForSale.get(...);
  }
}
</code></pre>

<p>Now in the main, I start an instance of class A, and an instance of class B.
inside class B, whenever I sell them an item, I want to update the purchasedItems and adjust the money of the class A instance in realtime (that means, inside the sellMeItem function of class B.)
Therefore I think I need the A instance to be global.
How can I reach the A object that is in the main from inside the class B sellMeItem function? (and class B instance is also in the main) </p>
