Using the System.out (which I've hidden to verify) it looks like this works. Not sure why it won't pass. any help please guys.
package com.codegym.task.task08.task0815;
import java.util.HashMap;
import java.util.HashSet;
/*
Census
*/
public class Solution {
public static HashMap<String, String> createMap() {
//write your code here
HashMap<String, String> map = new HashMap<String, String>();
map.put( "Map1" , "All1" );
map.put( "Map2" , "All2" );
map.put( "Map3" , "All3" );
map.put( "Map4" , "All4" );
map.put( "Map5" , "All5" );
map.put( "Map6" , "All6" );
map.put( "Map7" , "All7" );
map.put( "Map8" , "All8" );
map.put( "Map9" , "All9" );
map.put( "Map10" ,"All10" );
return map;
}
public static int getSameFirstNameCount(HashMap<String, String> map, String name) {
//write your code here
int countName = 0;
for ( HashMap.Entry<String, String> pair : map.entrySet() ) {
if ( pair.getValue().contains( name ) ) {
countName++;
} else {
}
}
//System.out.println( countName );
return countName;
}
public static int getSameLastNameCount(HashMap<String, String> map, String lastName) {
//write your code here
int countLastName = 0;
for ( HashMap.Entry<String, String> pair : map.entrySet() ) {
if ( pair.getKey().contains( lastName ) ) {
countLastName++;
} else {
}
}
//System.out.println( countLastName );
return countLastName;
}
public static void main(String[] args) {
HashMap<String, String> map = createMap();
getSameFirstNameCount( map , "All" );
getSameLastNameCount( map , "Map" );
}
}