title: java same ArrayList for multiple table model
body: <p>I am struggling to avoid data duplication with multiple JTable. Basically I have a TableModel which has an arraylist of data and a string[] header.</p>
  
  <p>So far nothing new. Now I have another TableModel which has the same arraylist of data BUT a different string[] header.</p>
  
  <p>I can't make my code to work. I would appreciate some idea on how to share the arrayList of data across multiple table model.</p>
  
  <p>So when I change  the data all models are updated and there isn't data duplication. I would like to avoid copy of arraylist
  any idea or am I wrong with this setup? I did try listener but I think going that way we still have data duplication across table model.</p>
  
  <pre><code>public class GymTableModel extends AbstractTableModel {
      private final ResourceBundle name = ResourceBundle.getBundle("labels/TableLabel", Locale.getDefault());
      private final String[] entete = {
          name.getString("LNAME"),
          name.getString("FNAME"),
          name.getString("CONTACT"),
          name.getString("TELFIX"),
          name.getString("TELGSM"),
          name.getString("EMAIL"),
          name.getString("BDATE"),
          name.getString("EDATE"),
          name.getString("LICENSE"),
          name.getString("AGE"),
          name.getString("ANCIEN")
      };
  
      @Override
      public Class&lt;?&gt; getColumnClass(int columnIndex){
          switch(columnIndex){
              case 6:
                  return Date.class;
              case 7:
                  return Date.class;
              case 9:
                  return Integer.class;
              default:
                  return Object.class;
          }
      }
  
      @Override
      public int getRowCount() {
          return gymList.size();
      }
  
      @Override
      public int getColumnCount() {
          return entete.length;
      }
  
      @Override
      public Object getValueAt(int rowIndex, int columnIndex) {
          switch(columnIndex){
              case 0:
                  return gymList.get(rowIndex).getLastName();
              case 1:
                  return gymList.get(rowIndex).getFirstName();
              case 2:
                  return gymList.get(rowIndex).getContact();
              case 3:
                  return gymList.get(rowIndex).getTelFix();
              case 4:
                  return gymList.get(rowIndex).getTelGsm();
              case 5:
                  return gymList.get(rowIndex).getEmail();
              case 6:
                  return gymList.get(rowIndex).getDateBirth();
              case 7:
                  return gymList.get(rowIndex).getDateClub();
              case 8:
                  return gymList.get(rowIndex).getLicence();
              case 9:
                  return gymList.get(rowIndex).getAge();
              case 10:
                  return gymList.get(rowIndex).getAnciennete();
              default:
                  return null; // should never happen;
          }
      }
  
      public String getColumnName(int columnIndex){
          return entete[columnIndex];
      }
  
  }
  </code></pre>
  
  <p>Now I have another table which has same data but only 3 columns (LNAME, FNAME and AGE) so getColumnClass isn't same. Question is, can I share my gymList data  (which is an arrayList) with another table model?
  Thankyou</p>