Getting Index out of bound exception for
for (int recordData = 0; recordData < recordDataList.size(); recordData++)
{
RecordData nextRecordData = recordDataList.get(recordData + 1);
if (nextRecordData.getRespondentId() !=
recordDataList.get(recordData).getRespondentId()) {
rowDataNumber++;
}
}
Here size is 3. But i need to compare third data with second also.
I have modified my like
for (int i = 1; i < recordDataList.size(); i++) {
RecordData recordData = recordDataList.get(i - 1);
RecordData nextRecordData = recordDataList.get(i);
commentData = recordData.getCommentText();
if (nextRecordData.getRespondentId() != recordData
.getRespondentId()) {
rowDataNumber++;
}
}
the size is three i am getting only first two data in commentData,the third data is not getting shown.
As you are comparing a value with the next value, there needs to be a next value.
You need to use
or