What do you mean, access Map.Entry? Do you mean that you iterate over the entrySet() each time? That's how it works.
There are actually three views you can use: keySet() for only the keys, values() for only the values and entrySet() for both. With entrySet() you need to have something that also contains both, and that's Map.Entry. That's why the iterator returns those.
jose chiramal wrote:Why Map does not support iterator ?
We need to use static interface Map.Entry every time to overcome this .
I think I must be missing something! If you want to iterate of the keys then use Map.keySet(). If you want to iterate of the values then use Map.values().
Are you wanting an iterator() method to provide an Iterator<Map.Entry<K,V> > ? If so then just use Map.entrySet().iterator().
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.