Getting an iterator
Iterator hmIterator = count . entrySet ( ) . iterator ( ) ; while ( hmIterator . hasNext ( ) ) { Map . Entry mapElement = ( Map . Entry ) hmIterator . next ( ) ; int number = ( int ) mapElement . getKey ( ) ; int frequency = ( int ) mapElement . getValue ( ) ;