title: How to increment my row counter variable in my while loop?
body: <p>I am trying to read in each row that has data in the first cell into an ArrayList of Objects. My problem is that my code doesn't seem to be incrementing my counter past the first row. Am I missing something simple?</p>
  
  <h1>Code</h1>
  
  <pre><code>        try
              {
                  wb = new XSSFWorkbook(new FileInputStream(fileName));
              } 
          catch (FileNotFoundException e)
              {
                  e.printStackTrace();
              } 
          catch (IOException e)
              {   
                  e.printStackTrace();
              }
  
          XSSFSheet sheet = wb.getSheetAt(2);
          ArrayList&lt;Object&gt; obj = new ArrayList&lt;Object&gt;();
          int rowIndex = 0;
          int cellIndex = 0;
          XSSFRow row = sheet.getRow(rowIndex);
          Iterator&lt;Cell&gt; rowItr = row.iterator();
  
          while(rowIndex &lt;= sheet.getLastRowNum())
              {
                  if(row.getCell(0) == null)
                      {
                          continue;
                      }
                  else
                      {
                          while(rowItr.hasNext() &amp;&amp; rowItr.next() != null)
                                      {
                                          XSSFCell cell = row.getCell(cellIndex);
  
                                          if(cell == null)
                                              {
                                                  continue;
                                              }
                                          else
                                              {       
                                                  obj.add(row.getCell(cellIndex).toString());
                                              }
                                          cellIndex++;
                                      }
  
                                  rowIndex++;
                                  cellIndex = 0;
  
                              }
  
                          System.out.println(obj.toString());
                      }
                  rowIndex++;
              }   
      }
  </code></pre>
  
  <h1>Output</h1>
  
  <pre><code>[ValuSmart Series 1120 Double Hung]
  </code></pre>
  
  <p>... <em>I get this output 72 times since there are 72 rows in the sheet</em></p>
  
  <h1>Isolated Loop</h1>
  
  <pre><code>ArrayList&lt;Object&gt; obj = new ArrayList&lt;Object&gt;();
  int rowCounter = 16;
          int x = 0;
  
          while(rowCounter &lt;= 21)
              {
  
                  XSSFRow row = sheet.getRow(rowCounter);
                  Iterator&lt;Cell&gt; rowItr = row.iterator();
  
                  while(rowItr.hasNext() &amp;&amp; rowItr.next() != null)
                      {
  
                                  XSSFCell cell = row.getCell(x);
  
  
                                  if(cell == null)
                                      {
                                          continue;
                                      }
                                  else
                                      {
  
                                          obj.add(row.getCell(x).toString());
                                      }
                          x++;
  
                      }
  
                  rowCounter++;
                  x = 0;
              }
          System.out.println(obj.toString());
  </code></pre>