I have two hashmaps let's say hashmap1 and hashmap2 so that hashmap2 contains common keys with hashmap1. So, I want to check that if the keys are common or equal in both hashmaps, then I multiply the values of hashmap2 by 2 in each iteration.
My code is as follows but it gives me zero. Actually, I want to practice the operation otherwise I can easily multiply the values of hashmap2 without comparing with hashmap1.
double mult=2;
for(String s:hashmap1.keySet()) {
if(hashmap1.keySet()==hashmap2.keySet()) {
mult= mult * hashmap1.get(s);
}else {
continue;
}
}
System.out.println("The new values for hashmap2: " + mult);
Moreover, the keys for hashmaps are String