I have the following Java code:
public void myMethod (final Map pFeatureGroupsFromPackage) {
final Set<String> keys = pFeatureGroupsFromPackage.keySet();
for (final String key : keys) {
tmpList = (List<FeatureKey>) pFeatureGroupsFromPackage.get(key);
// do whatever
}
}
I am getting a warning from "findBugs" telling the following:
Method myMethod
makes inefficient use of keySet iterator instead of entrySet iterator.
The warning is done at the tmpList
assignment.
I do not understand why this is inefficient. In fact the keys
list is computed only once.
Any comment? Thanks.