title: Three Classes, one Main, one for ArrayList, and one for print. how to make them work together?
body: <p>newbie here! Here's the problem. I wanted to make a separate class for custom methods on an ArrayList for food items, and another separate class on a method to use just for printing the food items created in ArrayList, and I wanted to call them in the Main method. here's what I wrote in the &quot;Foods&quot; class:</p>
  <pre><code>import java.util.ArrayList;
  
  public class Foods {
      
      ArrayList&lt;String&gt; foods = new ArrayList&lt;String&gt;();
      
      public void addFood(String input) {
          foods.add(input);
      }
      
      public void setFood(int number, String input) { 
          foods.set(number, input);
      }
      
      public void removeFood(int numebr) {
          foods.remove(numebr);
      }
      
      public void clearFood() {
          foods.clear();
      }
      
      public int sizeFood() {
          return foods.size();
      }
      
      public String getFood(int i) {
          return foods.get(i);
      }
  
  }
  </code></pre>
  <p>here's the &quot;Print&quot; class:</p>
  <pre><code>
  public class Print {
      
      public void printFoods() {
          
          Foods foods = new Foods();
          
          for (int i=0; i&lt;foods.sizeFood(); i++)
              System.out.println(foods.getFood(i));
      }
  
  }
  </code></pre>
  <p>and here's Main:</p>
  <pre><code>public class Main {
  
      public static void main(String[] args) {
          Foods foods = new Foods();
          Print print = new Print();
          
          foods.addFood(&quot;Beer&quot;);
          foods.addFood(&quot;Tequila&quot;);
          
          print.printFoods();
          
      }
  }
  </code></pre>
  <p>and the result is Blank!</p>
  <p>So to my understanding, I'm making two instances of &quot;Foods&quot; class, one in the Main class and another in Print class, and that's why when I call the print method I get blank result. so I tried to convert &quot;Print&quot; class to Static so It might see the initialization of Foods class in the Main class and therefore I could remove the instance of Foods class created in Print class. but since converting Print class to Static wasn't allowed, I'm stuck!</p>
  <p>I would really appreciate it if you guys could suggest a work around this issue. and one thing to mention, moving the print method to the Main class is a no go, cause I really want to keep different functions organized and separated from the main class.  thanks</p>