title: Accessing Objects Made in Array from Different Class
body: <p>i am having trouble trying to figure out how to access objects that were made in an array in another class from Main. Psuedo for what im trying to do.</p>
  
  <ul>
  <li>In Main CLass Prompt user for number of Tables In the Restaurant</li>
  <li>take number n, create array of n Table objects in Restaurant Class</li>
  <li>Access each tableobject created and be able to add values to it via constructor all from main</li>
  </ul>
  
  <p>Hopefully the code can Explain Better.</p>
  
  <p>My Main Class</p>
  
  <pre><code>Restaurant RestaurantObject = new Restaurant(); 
  Table TableObject = new Table();
  
  System.out.println("Max Tables In Restaurant? (Interger)");//Set Max Tables
  Scanner smax_tables = new Scanner(System.in);
  int max_tables = smax_tables.nextInt();
  RestaurantObject.create_table_array(TableObject, max_tables);
  </code></pre>
  
  <p>My Restaurant Class </p>
  
  <pre><code>private Table[] TableList; //and other random variables
  //other methods
  
  public void create_table_array(Table table,int number) {
          Table[] TableList = new Table[number];
          int i = 0;
          for(i = 0; i &lt; number; i++) {
              TableList[i] = table;
          }
  public Restaurant() {
  
  }
  </code></pre>
  
  <p>My Table CLass</p>
  
  <pre><code> int max_amount;
  
      public int getMax() {
          return max_amount
     }
  
      Table(int number) {
          this.max_amount = number;
      }
  </code></pre>
  
  <p>And my desired action</p>
  
  <ul>
  <li>run program and enter 5 for max tables</li>
  <li>5 tables created in restaurant</li>
  <li><code>RestaurantObject.Table1(10) //set max to 10 in table object</code></li>
  <li><code>System.out.printf("max amount for table1 is %d",Restaurant.Table1.getMax()</code></li>
  </ul>
  
  <p>Now that im re-looking at it. Would i have to prompt the user for the table to edit, get and return that table object in the array? Any help would be great,thanks</p>