Tried it with equals as well to no avail...
package com.codegym.task.task08.task0815;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
/*
Census
*/
public class Solution {
public static HashMap<String, String> createMap() {
HashMap<String, String> map = new HashMap<>();
map.put("joe", "ben");
map.put("jack", "richard");
map.put("Mitch", "danesh");
map.put("Kelly", "ben");
map.put("joe1", "danesh");
map.put("Kelly2", "richard");
map.put("jack3", "danesh");
map.put("Mitch2", "ben");
map.put("joe2", "gilfoyl");
map.put("Kelly3", "richard");
return map;
}
public static int getSameFirstNameCount(HashMap<String, String> map, String name) {
int nameCount = 0;
for (Map.Entry<String, String> pair : map.entrySet()) {
if (pair.getKey() == name) {
nameCount++;
}
}
return nameCount;
}
public static int getSameLastNameCount(HashMap<String, String> map, String lastName) {
int nameCount = 0;
for (Map.Entry<String, String> pair : map.entrySet()) {
if (pair.getValue() == lastName) {
nameCount++;
}
}
return nameCount;
}
public static void main(String[] args) {
}
}