I have a very basic java iterator scenario…in which am facing the below problem on finding the working of the iterator
Will the iterator logIterator have the same values in both the while loops,or it would have ended and become null in the second while loop.
Set logSet=transactionLogMap.entrySet();
Iterator logIterator=logSet.iterator();
BigDecimal tempRegId=null;
while (logIterator.hasNext()) {
tempRegId=(BigDecimal)logIterator.next();
}
if (someBoolean) {
while (logIterator.hasNext()) {
callsomeMethod(logIterator.next());
}
}
It will get to the end before the second loop, but it will not become null.
It will just return
falseforlogIterator.hasNext()