-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathamocana5.class
45 lines (37 loc) · 1.27 KB
/
amocana5.class
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.util.HashMap;
import java.util.Iterator;
/**
* Created by GeoLab on 10/25/15.
*/
public class amocana5 {
public static void main (String[]args){
HashMap<String, String> map1;
HashMap<String, String> map2;
map1 = new HashMap<>();
map2 = new HashMap<>();
map1.put("zamtari","civi");
map1.put("tevzi","shebolili");
map1.put("qatami","shemwvari");
map2.put("qatami","shemwvari");
map2.put("tevzi","shebolili");
map2.put("zamtari","civi");
System.out.println(commonKeyValuePairs(map1,map2));
}
public static int commonKeyValuePairs(HashMap<String, String> map1, HashMap<String, String> map2){
int counter = 0;
Iterator iterator1 = map1.keySet().iterator();
while(iterator1.hasNext()){
String key1 = (String) iterator1.next();
String value1 = map1.get(key1);
Iterator iterator2 = map2.keySet().iterator();
while (iterator2.hasNext()) {
String key2 = (String) iterator2.next();
String value2 = map2.get(key2);
if (key1.equals(key2) && value1.equals(value2)){
counter++;
}
}
}
return counter;
}
}