You can check the length of an array with a field length, for example:
if (tal.length > i + 1) {
}
As you did not say anything about your comparison line (the line containing ==), I think this is not part of the question.
Although I think you should put it in a for loop, for example:
for (int i=0; < tal.length - 1; i++) {
}
source
share