title: Java, filling Object[][] array with data
body: <p>I'm trying to fill an <code>Object[][]</code> array with data from my Object Class. However im having problems filling the array. Below is what I am trying to do to fill the <code>Object[][] data</code>. at the moment the returned data variable cannot be seen by the method. I have tried removing the method and filling the array where <code>rows</code> in declared but cannot because there is a for loop.</p>
  
  <p>Am I currently filling the <code>object[][]</code> array correctly?</p>
  
  <pre><code> public class CustomersDialog extends javax.swing.JDialog {
      private CustomerList customers = new CustomerList();
      Object rows[][] = getData();
  
      public Object[][] getData() {
         customers = dataManager.getUserData();
         int size = customers.size();
         Customer customer = new Customer();
  
         for(int i = 0; i &lt; size; i++) {
             customer = customers.getCustomerAt(i);
             Object [][] data = { 
             { Integer.toString(customer.getCustomerID()), customer.getfName(), customer.getlName() } };
         }
  
         return data;
      }
   }
  </code></pre>
  
  <p>Further doing this method of creating the array outside the loop causes an 'empty statement message' by the compiler and it says it 'requires line ends <code>;</code> after the <code>.get</code> statements':</p>
  
  <pre><code> public Object[][] getData() {
      customers = dataManager.getUserData();
      int size = customers.size();
      Customer customer;
  
      Object [][] data;
  
      for(int i = 0; i &lt; size; i++) {
          customer = customers.getCustomerAt(i);
          data = { 
          { Integer.toString(customer.getCustomerID()), customer.getfName(), customer.getlName() } };
      }
  
      return data;
  }
  </code></pre>