title: Java: Issue With Storing Data from Excel in an ArrayList of ArrayLists
body: <p>I'm trying to store data from excel in ArrayLists, which will then be stored in a main ArrayList. The reason being that each row of the excel sheet has data that is particular to that row. I keep having an issue because I believe when I erase the inner ArrayList before looping back, it deletes the data in the master ArrayList as well. </p>
  
  <pre><code>import java.io.*;
  import org.apache.poi.ss.usermodel.Cell;
  import org.apache.poi.ss.usermodel.Row;
  import org.apache.poi.ss.usermodel.Sheet;
  import org.apache.poi.ss.usermodel.Workbook;
  import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  import java.util.ArrayList;
  
  
  public class StoreData {
  
  ArrayList&lt;ArrayList&lt;String&gt;&gt; shapes;
  ArrayList&lt;String&gt; innerMembers;
  ArrayList&lt;String&gt; test;
  int start;
  int end; 
  
  public StoreData(){
      this.shapes = new ArrayList&lt;&gt;();
      this.innerMembers = new ArrayList&lt;&gt;();
      this.test = new ArrayList&lt;&gt;();
      start = 0;
      end = 0;
  }
  
  public ArrayList&lt;ArrayList&lt;String&gt;&gt; storeValues(String shapeType){
  
      //get the shape
      switch(shapeType){
          case "A":
              start = 1;
              end = 273;
              break;
          case "B":
              start = 274;
              end = 291;
              break;
          case "C":
              start = 292;
              end = 319;
              break;
          case "D":
              start = 320;
              end = 340;
              break;
          case "E":
              start = 341;
              end = 372;
              break;
          case "F":
              start = 373;
              end = 412;
              break;
          case "G":
              start = 413;
              end = 539;
              break;
          case "H":
              start = 540;
              end = 814;
              break;
          case "I":
              start = 1464;
              end = 1958;  
      }
  
   try
   {
      FileInputStream x = new FileInputStream(new File("/Users/JohnDoe/Documents/File.xls"));
  
      //Create Workbook instance 
      Workbook workbook = new HSSFWorkbook(x);
  
      //Get first/desired sheet from the workbook
      Sheet sheet = workbook.getSheetAt(0);
  
      //Iterate through each rows one by one
      for (int i = start; i &lt;= end; i ++){
  
          Row row = sheet.getRow(i++);
  
          //iterate through each cell in row: max number of cells is 76
          for (int j = 0; j &lt; 77; j++) {
  
              Cell cell = row.getCell(j);
              cell.setCellType(1);
              innerMembers.add(cell.getStringCellValue());
      }            
  
      /*******************/
      //Add to master ArrayList and clear inner ArrayList to get repopulated
      /*******************/
      shapes.add(innerMembers);
      innerMembers.clear();
  }
  x.close();
  }
  catch (Exception e)
  {
      e.printStackTrace();
  }
  
  /***TEST STATEMENT***/
  System.out.println(shapes.get(8).get(20));
  /***TEST STATEMENT***/
  
  return shapes;
  
  }
  }
  </code></pre>