When to use rowiterator and iterator for iterating through the rows of an excel sheet
<p>The code to read the contents of an excel spreadsheet (.xlsx) is included below. To iterate thru each row, I'm using <code>iterator()</code> method of sheet object, this works well. Also if I use <code>rowIterator()</code> method, it also works well. </p>

<p>What is the difference between these 2 functions and when to use which.</p>

<pre><code>{

FileInputStream fis = new FileInputStream(new File("E:\\readexcel.xlsx"));
XSSFWorkbook wb = new XSSFWorkbook(fis);
XSSFSheet sh = wb.getSheetAt(0);
Iterator&lt;Row&gt; rowIterator = sh.iterator(); // sh.rowIterator(); -- also works well
while(rowIterator.hasNext()){               
    Row row = rowIterator.next();               
    Iterator&lt;Cell&gt; cellIterator = row.iterator(); //row.cellIterator();-- also works well               
    while(cellIterator.hasNext()){                  
        Cell cell = cellIterator.next();
        System.out.print(cell.getStringCellValue()+"\t");
    }
                System.out.println("");
}

}
</code></pre>