I have not personally used this myself. Each entry in the Map is represented by a Map.Entry, and the entry set can be used to iterate through the entries. Useful if you need to access each entry as a whole.
I think I have used it and John Meyers is correct. I am writing from memory, but it goes something like this:- It was the only way I could find of gaining access to the "V" entries in a HashMap in order without knowing the "K" values. Of course, you can get access to the "K" values using getKey() instead of getValue().
If you just need keys, use keySet(). If you just need values, use values(). If you're going to use keys and values in your subsequent code, then you're best off using entrySet().
I frequently see people do this without entrySet(), and it usually looks something like this:
This works, but it's making the JVM do extra work for no good reason. Every time you call get() you're making the JVM spend time doing a hashcode lookup, or navigating a tree and evaluating a comparator. These operations may be fast, or not, but why do them if you don't have to? A Map.Entry gives you both key and value, together, in the most efficient manner possible.
Whenever I am getting all the data out of the Map I use entrySet. I do use it a lot. Especially when copying the Map, or converting it into a different format. Most recently I created a database dump to xml and I had to get all the contents of a Map. I used entryset.