I need to iterate over the set of values for each iteration of for loop, but only for first iteration it works fine. Thereafter the itr.hasNext()
returns
It depends on the exact contents of your code block, but why not flip the loops? Have the outer loop go over the file, and for each iteration, go over all the Person
s:
Iterator itr = getQuestionIterator(File file);
while(itr.hasNext())
{
String question = itr.next();
for(Person p : persons)
{
........
........
}
}