Why does the top code work and the bottom one not?
They are the same code after all..........
public static int getSameLastNameCount(HashMap<String, String> map, String lastName) {
//write your code here
int counter = 0; // counter for same first name
for (HashMap.Entry<String, String> pair : map.entrySet())
{
if (pair.getKey().equalsIgnoreCase(lastName)) counter++;
}
return counter;
/*
int lastNameCount = 0;
for (HashMap.Entry<String, String> pair : map.entrySet()){
if(pair.getKey().equalsIgnoreCase(lastName));
lastNameCount++;
}
return lastNameCount;
*/
hidden #10444738
Level 16
One fails one doesn't
Resolved
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
prathameshbagekari
29 July 2019, 17:41
In lastName it should be getValue()..
0
hidden #10444738
27 June 2019, 09:39solution
GDI.
found it myself, a bloody semi-colon on the if statement. pmsl!
+2