Multiplying Values of Two HashMaps

Given that the two HashMaps have equal amount of entries, and that all the entries have the same corresponding key, then a solid way to aquire the sum would be like this:

double sum = 0;

/* iterate through all the keys in hm1 */
/* order doesn't matter */
for (String key : hm1.keySet()) {
    double value1 = hm1.get(key);
    double value2 = hm2.get(key);
    sum += value1 * value2;
}