SyntaxFix
Write A Post
Hire A Developer
Questions
An Iterator moves forward only, if it read it once, it's done. Your
Iterator
m.get(itr2.next());
is reading the next value of itr2.next();, that is why you are missing a few (actually not a few, every other) keys.
itr2.next();