Reputation: 1713
I want to loop through all rows until I encounter null
int startRow = 4;
ArrayList<String> uniques = new ArrayList<String>();
int k = 0 ;
while (sheet.getRow(startRow+k).getCell(2) != null) { // null pointer here ?
uniques.add(sheet.getRow(startRow+k).getCell(2).toString());
k++ ;
}
I get a NullPointerException
.
Upvotes: 0
Views: 2183
Reputation: 178263
You are checking the Cell
if it's null
, but not the Row
itself.
while (sheet.getRow(startRow+k) != null &&
sheet.getRow(startRow+k).getCell(2) != null) {
Upvotes: 3