I am traversing over my allRecords list that is of type Abc using an iterator. To keep track of the elements iterated, i keep a position variable.
I use this position variable to further apply some logic in my program.
Code snippet is as follows:
Abc abc;
Iterator<Abc> iterator = allRecords.iterator();
while (iterator.hasNext()) {
abc = iterator.next();
position++;
//validate the abc object with some conditions and break the loop if matches
//I will have that position where the condition matched
}
My question is can I use some of Java's latest stream API or lambda expression to fulfill this task.
Any help would be appreciated.